root indicator and err indicator
This commit is contained in:
parent
99305cecbe
commit
94559380d3
29
src/main.rs
29
src/main.rs
@ -102,22 +102,33 @@ fn main() -> std::io::Result<()> {
|
||||
let angle = "❯";
|
||||
|
||||
//Root user indicator
|
||||
let _user = var_os("USER").expect("UnknownUser").to_str().expect("UnknownUser").to_string();
|
||||
/*
|
||||
if user == "root" {
|
||||
println!("root_user");
|
||||
}*/
|
||||
let user = var_os("USER").expect("UnknownUser").to_str().expect("UnknownUser").to_string();
|
||||
|
||||
let mut err = "";
|
||||
|
||||
//Shell symbol
|
||||
let args: Vec<String> = args().collect();
|
||||
let shell: String;
|
||||
if args.len() > 1 {
|
||||
shell = args[1].clone();
|
||||
if args.len() > 2 {
|
||||
err = args[2].as_str();
|
||||
}
|
||||
}
|
||||
else {
|
||||
shell = "none".to_string();
|
||||
}
|
||||
|
||||
let root_indicator = match user.as_str() {
|
||||
"root" => angle.truecolor(255, 53, 94),
|
||||
_ => angle.truecolor(0, 255, 180),
|
||||
};
|
||||
|
||||
let err_indicator = match err {
|
||||
"0" => angle.truecolor(0, 255, 180),
|
||||
_ => angle.truecolor(255, 53, 94),
|
||||
};
|
||||
|
||||
//SSH shell indicator
|
||||
let ssh_char:ColoredString;
|
||||
match var_os("SSH_TTY") {
|
||||
@ -125,7 +136,7 @@ fn main() -> std::io::Result<()> {
|
||||
ssh_char = " ".truecolor(0,150,180);
|
||||
},
|
||||
None => {
|
||||
ssh_char = "".truecolor(34,109,155);
|
||||
ssh_char = "".clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,14 +154,16 @@ fn main() -> std::io::Result<()> {
|
||||
cur_dir = cur_dir.replace(&homedir, "~"); // Abreviate homedir with "~"
|
||||
cur_dir = abrev_path(cur_dir);
|
||||
|
||||
print!("{}{}{}{}{}{} ",
|
||||
print!("{}{}{}{}{}{}{} ",
|
||||
ssh_char,
|
||||
get_shell_char(shell).truecolor(75,75,75),
|
||||
git_repo_name,
|
||||
git_char,
|
||||
//abrev_path(pwd,homedir).italic().truecolor(82,82,82),
|
||||
cur_dir.italic().truecolor(82,82,82),
|
||||
angle.truecolor(0, 255, 180),
|
||||
//angle.truecolor(0, 255, 180),
|
||||
root_indicator,
|
||||
err_indicator,
|
||||
);
|
||||
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user