minor code formatting, cleanup

This commit is contained in:
Candifloss 2024-08-15 02:33:53 +05:30
parent 84ee4983ae
commit bf36aaaf6f

View File

@ -1,10 +1,7 @@
use std::env::current_dir;
use std::env::var_os;
use std::env::args;
use std::env::{current_dir,var_os,args};
use std::path::PathBuf;
use colored::{Colorize,ColoredString};
//use std::ffi::OsString;
use colored::Colorize;
use colored::ColoredString;
fn get_shell_char (shell: String) -> String {
let shell_char = match shell.as_str() {
@ -36,13 +33,12 @@ fn abrev_path (pwd: PathBuf, homedir: String) -> String {
if slashes > 3 {
let parts: Vec<&str> = path.split("/").collect();
let len = parts.len() - 1;
let mut fch: String;
let mut ch1: String;
for p in &parts[0..len] {
let part = p;
for part in &parts[0..len] {
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);
ch1 = part.chars().next().expect(part).to_string(); // 1st char of each part
short_dir = short_dir.replace(part, &ch1);
}
}
}
@ -71,8 +67,8 @@ fn main() -> std::io::Result<()> {
}*/
match var_os("SSH_TTY") {
Some(_val) => {
ssh_char = "".truecolor(34,109,155);
ssh_char_space = " ".to_string();
ssh_char = "".on_truecolor(0,150,180).truecolor(20,20,20);
ssh_char_space = " ";//.to_string();
},
None => {
ssh_char = "".truecolor(34,109,155);
@ -85,6 +81,7 @@ fn main() -> std::io::Result<()> {
get_shell_char(shell).truecolor(75,75,75),
abrev_path(pwd,homedir).italic().truecolor(82,82,82),
angle.truecolor(0, 255, 180),
);
);
Ok(())
}