diff --git a/src/ps.rs b/src/ps.rs index d63e653..496480d 100644 --- a/src/ps.rs +++ b/src/ps.rs @@ -1,21 +1,26 @@ use const_format::formatcp; -use color_print::{cformat, cprint}; pub const DEFAULT_PS: &str = formatcp!("lambdashell-{}", env!("CARGO_PKG_VERSION")); -pub fn working_dir_name() -> String { - std::env::current_dir().map_or("?".to_owned(), |path| { - path.file_name().map_or("?".to_owned(), |name| { - let name_os_string = name.to_os_string(); - match name_os_string == whoami::username_os() && name_os_string != "root" { - true => "~".to_owned(), - false => name.to_string_lossy().to_string(), - } - }) - }) -} +struct Ps(String); +impl Ps { + fn set(prompt: String) -> Self { + Self(prompt) + } -pub fn display(ps1: &String) { - let working_dir_name = cformat!(" {} ", working_dir_name()); - cprint!("{}{}λ ", ps1, working_dir_name); -} + fn working_dir_name(&self) -> String { + std::env::current_dir().map_or("?".to_owned(), |path| { + path.file_name().map_or("?".to_owned(), |name| { + let name_os_string = name.to_os_string(); + match name_os_string == whoami::username_os() && name_os_string != "root" { + true => "~".to_owned(), + false => name.to_string_lossy().to_string(), + } + }) + }) + } + + fn display(&self) { + print!("{}", self.0); + } +} \ No newline at end of file