added pretty names.
This commit is contained in:
parent
b43e1491e7
commit
295cdec9fa
87
Cargo.lock
generated
87
Cargo.lock
generated
@ -28,12 +28,6 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.11.1"
|
||||
@ -293,17 +287,6 @@ dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.27.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ntapi"
|
||||
version = "0.4.0"
|
||||
@ -353,15 +336,13 @@ name = "oxidefetch"
|
||||
version = "1.3.2"
|
||||
dependencies = [
|
||||
"byte-unit",
|
||||
"cfg-if",
|
||||
"chrono",
|
||||
"colored",
|
||||
"compound_duration",
|
||||
"nix",
|
||||
"lazy_static",
|
||||
"quoted-string",
|
||||
"sysinfo",
|
||||
"whoami",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -602,69 +583,3 @@ name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
||||
|
@ -10,6 +10,7 @@ byte-unit = "4.0.18"
|
||||
chrono = "0.4.23"
|
||||
colored = "2.0.0"
|
||||
compound_duration = "1.2.0"
|
||||
lazy_static = "1.4.0"
|
||||
quoted-string = "0.6.1"
|
||||
sysinfo = "0.28.1"
|
||||
whoami = "1.3.0"
|
||||
|
@ -1,6 +1,23 @@
|
||||
use std::env;
|
||||
use std::collections::HashMap;
|
||||
use lazy_static::lazy_static;
|
||||
use sysinfo::{Pid, PidExt, ProcessExt, System, SystemExt};
|
||||
|
||||
lazy_static! {
|
||||
static ref PRETTY_NAMES: HashMap<&'static str, &'static str> = {
|
||||
let mut m = HashMap::new();
|
||||
m.insert("cmd", "Command Prompt");
|
||||
m.insert("powershell", "PowerShell");
|
||||
m.insert("konsole", "Konsole");
|
||||
m.insert("gnome-terminal", "GNOME Terminal");
|
||||
m.insert("xterm", "XTerm");
|
||||
m.insert("xfce4-terminal", "XFCE Terminal");
|
||||
m.insert("kitty", "KiTTY");
|
||||
m.insert("alacritty", "Alacritty");
|
||||
m
|
||||
};
|
||||
}
|
||||
|
||||
// Allows detection of shells that host themselves (i.e. Command Prompt).
|
||||
const SELF_HOSTED_SHELLS: [&str; 2] = [
|
||||
"cmd.exe",
|
||||
@ -95,7 +112,15 @@ pub fn get_terminal() -> Option<String> {
|
||||
|
||||
return match name {
|
||||
Some(f) => {
|
||||
Some(f.split(".").nth(0).unwrap().to_string())
|
||||
// Remove the file extension.
|
||||
let mut res = f.split(".").nth(0).unwrap().to_string();
|
||||
|
||||
// Try to get a "prettier name".
|
||||
if PRETTY_NAMES.contains_key(res.as_str()) {
|
||||
res = PRETTY_NAMES.get(res.as_str()).unwrap().to_string();
|
||||
}
|
||||
|
||||
Some(res)
|
||||
},
|
||||
None => None,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user