From 3fad890e7480a230152da8a799a5c6068f1a4963 Mon Sep 17 00:00:00 2001 From: NerdyPepper Date: Sun, 19 May 2019 18:24:52 +0530 Subject: init --- src/main.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/main.rs diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..6ddfe0f --- /dev/null +++ b/src/main.rs @@ -0,0 +1,31 @@ +use std::env; +use tico::tico; + +fn main() { + println!("{}", cwd()); + println!("{}", prompt_char()); +} + +fn cwd() -> String { + let path = env::var("PWD").unwrap(); + let short_or_not = env::var("SHORTEN_CWD").unwrap_or("1".into()); + + match short_or_not.as_ref() { + "0" => path, + _ => tico(&path[..]) + } +} + +fn prompt_char() -> String { + let user_char = env::var("PROMPT_CHAR").unwrap_or("$ ".into()); + let root_char = env::var("PROMPT_CHAR_ROOT").unwrap_or("# ".into()); + + let euid = unsafe { libc::geteuid() }; + match euid { + 0 => return root_char, + _ => return user_char + } +} + +fn vcs() -> String { +} -- cgit v1.2.3