summaryrefslogtreecommitdiffstats
path: root/src/readline.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-12-09 17:15:17 -0500
committerJesse Luehrs <doy@tozt.net>2021-12-09 17:15:17 -0500
commitc2c6adf5b755b33e6b844a502cd8d61eabf89126 (patch)
tree58f7f78f7ff5218e5535da94be992d422e1035b4 /src/readline.rs
parentdb7ec0a00096a0ba70cb630a7852bf6751e3ce4c (diff)
downloadnbsh-c2c6adf5b755b33e6b844a502cd8d61eabf89126.tar.gz
nbsh-c2c6adf5b755b33e6b844a502cd8d61eabf89126.zip
refactor
Diffstat (limited to 'src/readline.rs')
-rw-r--r--src/readline.rs22
1 files changed, 5 insertions, 17 deletions
diff --git a/src/readline.rs b/src/readline.rs
index 38c1e51..479c76f 100644
--- a/src/readline.rs
+++ b/src/readline.rs
@@ -59,25 +59,13 @@ impl Readline {
focus: bool,
offset: time::UtcOffset,
) -> anyhow::Result<()> {
- let mut pwd = std::env::current_dir()?.display().to_string();
- let home = std::env::var("HOME")?;
- if pwd.starts_with(&home) {
- pwd.replace_range(..home.len(), "~");
- }
- let user = users::get_current_username()
- .unwrap()
- .to_string_lossy()
- .into_owned();
- let mut hostname =
- hostname::get().unwrap().to_string_lossy().into_owned();
- if let Some(idx) = hostname.find('.') {
- hostname.truncate(idx);
- }
+ let pwd = crate::env::pwd()?;
+ let user = crate::env::user()?;
+ let hostname = crate::env::hostname()?;
+ let time = crate::env::time(offset)?;
+
let id = format!("{}@{}", user, hostname);
let idlen: u16 = id.len().try_into().unwrap();
- let time = crate::format::time(
- time::OffsetDateTime::now_utc().to_offset(offset),
- );
let timelen: u16 = time.len().try_into().unwrap();
out.move_to(self.size.0 - 2, 0);