Add path to prompt (#444)

* Add path to prompt

* Change tilde position in font

* Update moros.png
This commit is contained in:
Vincent Ollivier 2022-11-28 23:21:05 +01:00 committed by GitHub
parent d156639604
commit 3be0a0c9a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

View File

@ -83,10 +83,21 @@ fn shell_completer(line: &str) -> Vec<String> {
}
pub fn prompt_string(success: bool) -> String {
let csi_color = Style::color("Magenta");
let csi_line1 = Style::color("Blue");
let csi_line2 = Style::color("Magenta");
let csi_error = Style::color("Red");
let csi_reset = Style::reset();
format!("{}>{} ", if success { csi_color } else { csi_error }, csi_reset)
let mut current_dir = sys::process::dir();
if let Some(home) = sys::process::env("HOME") {
if current_dir.starts_with(&home) {
let n = home.len();
current_dir.replace_range(..n, "~");
}
}
let line1 = format!("{}{}{}", csi_line1, current_dir, csi_reset);
let line2 = format!("{}>{} ", if success { csi_line2 } else { csi_error }, csi_reset);
format!("{}\n{}", line1, line2)
}
fn is_globbing(arg: &str) -> bool {