diff --git a/src/indicators/path.rs b/src/indicators/path.rs new file mode 100644 index 0000000..504b503 --- /dev/null +++ b/src/indicators/path.rs @@ -0,0 +1,13 @@ +use ansi_term::ANSIGenericString; +use ansi_term::Colour::RGB; +use std::env::current_dir; + +pub const PATH_COL: ansi_term::Colour = RGB(82, 82, 82); // + +pub fn pwd() -> ANSIGenericString<'static, str> { + let path = current_dir().map_or_else( + |_| "~~".to_string(), + |path| path.to_string_lossy().to_string(), + ); + PATH_COL.italic().paint(path) +} diff --git a/src/main.rs b/src/main.rs index 4039fd9..9d4094b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,14 @@ mod indicators { pub mod error; pub mod git; + pub mod path; pub mod ssh; pub mod user; } + use crate::indicators::error; use crate::indicators::git; +use crate::indicators::path; use crate::indicators::ssh; use crate::indicators::user; @@ -17,7 +20,11 @@ fn main() { let indicate_ssh: bool = true; let indicate_err: bool = true; let indicate_git_branch: bool = true; + let pwd: bool = true; + if pwd { + prompt += &path::pwd().to_string(); + } if indicate_ssh { prompt += &ssh::indicator().to_string(); }