Skip to content

Commit

Permalink
added color printing of user, machine and location
Browse files Browse the repository at this point in the history
  • Loading branch information
bexxmodd committed Jul 20, 2021
1 parent 3d72693 commit 52c3fb2
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
/.idea
28 changes: 28 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ users = "0.11"
sysinfo = "0.17"
dirs = "3.0"
chrono = "0.4"

termion = "*"
20 changes: 17 additions & 3 deletions src/shellname.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use sysinfo::SystemExt;
use termion::color;

pub struct ShellName {
name: String,
Expand All @@ -12,7 +13,14 @@ impl ShellName {
ShellName {
name: user.clone(),
current_dir: current_dir.to_string(),
shell_name: user + ":" + current_dir + "§ ",
shell_name: format!(
"{}{}{}:{}§ {}",
color::Fg(color::Red),
user,
color::Fg(color::Cyan),
current_dir,
color::Fg(color::Reset),
),
}
}

Expand All @@ -25,8 +33,14 @@ impl ShellName {
self.current_dir = dir.to_string();
}
}

self.shell_name = self.name.to_string() + ":" + &self.current_dir + "§ ";
self.shell_name = format!(
"{}{}{}:{}§ {}",
color::Fg(color::Red),
self.name.to_string(),
color::Fg(color::Cyan),
&self.current_dir,
color::Fg(color::Reset),
)
}
}

Expand Down

0 comments on commit 52c3fb2

Please sign in to comment.