|
@ -1,4 +1,4 @@ |
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
|
use std::env;
|
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
#[derive(Clone)]
|
|
|
pub enum PromptStyle {
|
|
|
pub enum PromptStyle {
|
|
@ -7,18 +7,20 @@ pub enum PromptStyle { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
impl PromptStyle {
|
|
|
impl PromptStyle {
|
|
|
pub fn fmt_style(&self, path: PathBuf) -> String {
|
|
|
|
|
|
|
|
|
pub fn fmt_style(&self) -> String {
|
|
|
match self {
|
|
|
match self {
|
|
|
PromptStyle::None => self.fmt_none(path),
|
|
|
|
|
|
PromptStyle::SimpleDirectory => self.fmt_simple_directory(path),
|
|
|
|
|
|
|
|
|
PromptStyle::None => self.fmt_none(),
|
|
|
|
|
|
PromptStyle::SimpleDirectory => self.fmt_simple_directory(),
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
fn fmt_none(&self, _: PathBuf) -> String {
|
|
|
|
|
|
|
|
|
fn fmt_none(&self) -> String {
|
|
|
return "» ".to_string();
|
|
|
return "» ".to_string();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
fn fmt_simple_directory(&self, path: PathBuf) -> String {
|
|
|
|
|
|
|
|
|
fn fmt_simple_directory(&self) -> String {
|
|
|
|
|
|
let path = env::current_dir().unwrap_or_default();
|
|
|
|
|
|
|
|
|
return format!("{} » ", path.to_string_lossy());
|
|
|
return format!("{} » ", path.to_string_lossy());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@ -35,8 +37,6 @@ impl Prompt { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
pub fn get_prompt(&mut self) -> String {
|
|
|
pub fn get_prompt(&mut self) -> String {
|
|
|
let path = std::env::current_dir().unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
return self.style.fmt_style(path);
|
|
|
|
|
|
|
|
|
return self.style.fmt_style();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|