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 = "❯";
|
let angle = "❯";
|
||||||
|
|
||||||
//Root user indicator
|
//Root user indicator
|
||||||
let _user = var_os("USER").expect("UnknownUser").to_str().expect("UnknownUser").to_string();
|
let user = var_os("USER").expect("UnknownUser").to_str().expect("UnknownUser").to_string();
|
||||||
/*
|
|
||||||
if user == "root" {
|
let mut err = "";
|
||||||
println!("root_user");
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//Shell symbol
|
//Shell symbol
|
||||||
let args: Vec<String> = args().collect();
|
let args: Vec<String> = args().collect();
|
||||||
let shell: String;
|
let shell: String;
|
||||||
if args.len() > 1 {
|
if args.len() > 1 {
|
||||||
shell = args[1].clone();
|
shell = args[1].clone();
|
||||||
|
if args.len() > 2 {
|
||||||
|
err = args[2].as_str();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
shell = "none".to_string();
|
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
|
//SSH shell indicator
|
||||||
let ssh_char:ColoredString;
|
let ssh_char:ColoredString;
|
||||||
match var_os("SSH_TTY") {
|
match var_os("SSH_TTY") {
|
||||||
@ -125,7 +136,7 @@ fn main() -> std::io::Result<()> {
|
|||||||
ssh_char = " ".truecolor(0,150,180);
|
ssh_char = " ".truecolor(0,150,180);
|
||||||
},
|
},
|
||||||
None => {
|
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 = cur_dir.replace(&homedir, "~"); // Abreviate homedir with "~"
|
||||||
cur_dir = abrev_path(cur_dir);
|
cur_dir = abrev_path(cur_dir);
|
||||||
|
|
||||||
print!("{}{}{}{}{}{} ",
|
print!("{}{}{}{}{}{}{} ",
|
||||||
ssh_char,
|
ssh_char,
|
||||||
get_shell_char(shell).truecolor(75,75,75),
|
get_shell_char(shell).truecolor(75,75,75),
|
||||||
git_repo_name,
|
git_repo_name,
|
||||||
git_char,
|
git_char,
|
||||||
//abrev_path(pwd,homedir).italic().truecolor(82,82,82),
|
//abrev_path(pwd,homedir).italic().truecolor(82,82,82),
|
||||||
cur_dir.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(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user