summaryrefslogtreecommitdiffstats
path: root/src/env.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-12-09 18:38:05 -0500
committerJesse Luehrs <doy@tozt.net>2021-12-09 18:38:05 -0500
commitf1878e73c2892da9b929a11c2ee805d9b46f7e6b (patch)
tree41758b3848e99a61abf1cfbd331e331d4eb224fc /src/env.rs
parentc2c6adf5b755b33e6b844a502cd8d61eabf89126 (diff)
downloadnbsh-f1878e73c2892da9b929a11c2ee805d9b46f7e6b.tar.gz
nbsh-f1878e73c2892da9b929a11c2ee805d9b46f7e6b.zip
this doesn't need to be modifiable
Diffstat (limited to 'src/env.rs')
-rw-r--r--src/env.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/env.rs b/src/env.rs
index 676b20e..b3a38c6 100644
--- a/src/env.rs
+++ b/src/env.rs
@@ -15,6 +15,14 @@ pub fn user() -> anyhow::Result<String> {
.into_owned())
}
+pub fn prompt_char() -> anyhow::Result<String> {
+ if users::get_current_uid() == 0 {
+ Ok("#".into())
+ } else {
+ Ok("$".into())
+ }
+}
+
pub fn hostname() -> anyhow::Result<String> {
let mut hostname = hostname::get()?.to_string_lossy().into_owned();
if let Some(idx) = hostname.find('.') {