diff options
| author | Jonas Maier <> | 2026-03-07 20:49:52 +0100 |
|---|---|---|
| committer | Jonas Maier <> | 2026-03-07 20:49:52 +0100 |
| commit | df5eec13a031d41232e7407794e2f5b9a0a2d608 (patch) | |
| tree | a76fba2ed68928d82d9b8352bfd0afc33d118fb0 /src/run/builtin.rs | |
| parent | 86cdb8c21dec737a3f0a40311782de851c1203d1 (diff) | |
| download | pish-df5eec13a031d41232e7407794e2f5b9a0a2d608.tar.gz | |
history with relative time
Diffstat (limited to 'src/run/builtin.rs')
| -rw-r--r-- | src/run/builtin.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/run/builtin.rs b/src/run/builtin.rs index b791861..c9456cd 100644 --- a/src/run/builtin.rs +++ b/src/run/builtin.rs @@ -27,12 +27,8 @@ impl Builtin for cd { std::mem::swap(&mut dir, &mut se.lock().unwrap().prev_path); let target_path: BString = match args.get(0).map(|v| &v[..]) { - Some(b"-") => { - dir - } - Some(path) => { - path.to_vec() - } + Some(b"-") => dir, + Some(path) => path.to_vec(), None => { if let Some(home) = std::env::var_os("HOME") { home.into_encoded_bytes() @@ -223,10 +219,16 @@ impl Builtin for history { _stdin: &mut dyn Read, stdout: &mut dyn Write, ) -> Result { - // TODO: better history querying let hist = session.lock().unwrap().history.clone(); + let now = crate::date::DateTime::now(); for entry in hist { - stdout.write_all(&entry)?; + let delta = now.relative_to(&entry.time); + for _ in 0..crate::date::DateTime::longest_reasonable_delta() - delta.len() { + stdout.write_all(b" ")?; + } + stdout.write_all(delta.as_bytes())?; + stdout.write_all(b" ")?; + stdout.write_all(&entry.cmd)?; stdout.write_all(b"\n")?; } Ok(()) |
