diff --git a/Cargo.lock b/Cargo.lock index 820fe20..86f02e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -186,16 +186,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "gethostname" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a329e22866dd78b35d2c639a4a23d7b950aeae300dfd79f4fb19f74055c2404" -dependencies = [ - "libc", - "windows", -] - [[package]] name = "getrandom" version = "0.2.8" @@ -303,7 +293,6 @@ dependencies = [ "crossbeam-channel", "ctrlc", "dirs", - "gethostname", "once_cell", "regex", "rustyline", @@ -600,21 +589,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows" -version = "0.43.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04662ed0e3e5630dfa9b26e4cb823b817f1a9addda855d973a9458c236556244" -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-sys" version = "0.42.0" diff --git a/Cargo.toml b/Cargo.toml index 64f01cb..972f671 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,6 @@ colored = "2.0" crossbeam-channel = "0.5" ctrlc = "3.2" dirs = "4.0" -gethostname = "0.4" once_cell = "1.17" regex = "1.7" rustyline = "10.1" diff --git a/src/prompt.rs b/src/prompt.rs index 76c4dcb..a79164b 100644 --- a/src/prompt.rs +++ b/src/prompt.rs @@ -1,5 +1,6 @@ use colored::Colorize; use std::env; +use whoami::{hostname, username}; #[derive(Clone)] pub enum PromptStyle { @@ -64,11 +65,7 @@ impl PromptStyle { .unwrap_or_default() }; - let username = home.file_name().unwrap_or_default().to_string_lossy(); - let _hostname = gethostname::gethostname(); - let hostname = _hostname.to_string_lossy(); - - format!("[{}@{} {}]$ ", username, hostname, dir_as_string) + format!("[{}@{} {}]$ ", username(), hostname(), dir_as_string) } }