diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/PrettyPrompt.iml b/.idea/PrettyPrompt.iml new file mode 100644 index 0000000..cf84ae4 --- /dev/null +++ b/.idea/PrettyPrompt.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..3792141 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index e37338f..3516d86 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,12 +4,13 @@ use std::env::args; use std::path::PathBuf; //use std::ffi::OsString; use colored::Colorize; +use colored::ColoredString; fn get_shell_char (shell: String) -> String { let shell_char = match shell.as_str() { "bash"|"/bin/bash" => "", - "zsh"|"/bin/zsh"|"/usr/bin/zsh" + "zsh"|"/bin/zsh"|"/usr/bin/zsh"|"-zsh" => "󰰶", "fish" => "󰈺", @@ -39,8 +40,8 @@ fn abrev_path (pwd: PathBuf, homedir: String) -> String { for p in &parts[0..len] { let part = p; - if part.to_string() != "" { // to avoid "/" - fch = part.chars().next().expect(p).to_string(); //1st char of p + if part.to_string() != "" { // to avoid the 1st "/" + fch = part.chars().next().expect(p).to_string(); // 1st char of p short_dir = short_dir.replace(part, &fch); } } @@ -55,7 +56,8 @@ fn main() -> std::io::Result<()> { let shell: String; let _user = var_os("USER").expect("UnknownUser").to_str().expect("UnknownUser").to_string(); let homedir = var_os("HOME").expect("UnknownDir").to_str().expect("UnknownDir").to_string(); - + let ssh_char:ColoredString; + let mut ssh_char_space: String = "".to_string(); if args.len() > 1 { shell = args[1].clone(); @@ -67,10 +69,21 @@ fn main() -> std::io::Result<()> { if user == "root" { println!("heh"); }*/ + match var_os("SSH_TTY") { + Some(_val) => { + ssh_char = "".truecolor(34,109,155); + ssh_char_space = " ".to_string(); + }, + None => { + ssh_char = "".truecolor(34,109,155); + } + } - print!("{} {}{} ", + print!("{}{}{} {}{} ", + ssh_char, + ssh_char_space, get_shell_char(shell).truecolor(75,75,75), - abrev_path(pwd,homedir).italic().truecolor(75,75,75), + abrev_path(pwd,homedir).italic().truecolor(82,82,82), angle.truecolor(0, 255, 180), ); Ok(())