F6L2P7VTKQUV64O66XPEIRG46ZO36E4FWFN3KNMBPRHQLQWL6HSAC
[[package]]
name = "arrayref"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544"
[[package]]
name = "arrayvec"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi",
]
]
[[package]]
name = "constant_time_eq"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
[[package]]
name = "crossbeam-utils"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
dependencies = [
"autocfg",
"cfg-if",
"lazy_static",
]
[[package]]
name = "redox_syscall"
version = "0.1.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
[[package]]
name = "redox_users"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d"
dependencies = [
"getrandom",
"redox_syscall",
"rust-argon2",
store::new()
.get_nth_entries(25)?
.into_iter()
.map(|entry| handle.write_all(format!("{:?}\n", entry).as_bytes()))
.collect::<Result<_, _>>()?;
let entries = store::new().get_nth_entries(&hostname, 25)?;
let mut table = Table::new();
table.set_format(*format::consts::FORMAT_CLEAN);
table.set_titles(row![b->"time", b->"session", b->"pwd", b->"command"]);
for entry in entries.into_iter() {
table.add_row(row![
format_timestamp(entry.time_finished),
format_uuid(entry.session_id),
format_pwd(entry.pwd),
format!("{}", entry.command),
]);
}
table.printstd();
fn format_timestamp(timestamp: DateTime<Utc>) -> String {
let today = Utc::now().date();
if timestamp.date() == today {
timestamp.format("%H:%M").to_string()
} else {
timestamp.date().format("%m/%d").to_string()
}
}
fn format_uuid(uuid: Uuid) -> String {
let chars = uuid.to_string().chars().collect::<Vec<_>>();
vec![chars[0], chars[1], chars[3], chars[4]]
.into_iter()
.collect()
}
fn format_pwd(pwd: PathBuf) -> String {
let home = std::env::var("HOME").unwrap();
if pwd.starts_with(home) {
let mut without_home = PathBuf::from("~");
let pwd_components = pwd.components().into_iter();
let pwd_components = pwd_components.skip(3);
pwd_components.for_each(|component| without_home.push(component));
without_home.to_string_lossy().to_string()
} else {
pwd.to_string_lossy().to_string()
}
}