From e3112dba1d9176d068455a1e3b2b2a8ccb90a5b4 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 4 Aug 2024 17:18:27 +0300 Subject: [PATCH] trim shell name to omit store path --- src/system.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/system.rs b/src/system.rs index cfd7745..bc770b7 100644 --- a/src/system.rs +++ b/src/system.rs @@ -15,13 +15,10 @@ pub fn get_username_and_hostname() -> Result { } pub fn get_shell() -> Result { - // In some setups, $SHELL is set to the store path - // of the actual shell program. While we can consider - // trimming by name, I will leave it to the user to handle - // what their SHELL variable is really set to. - let shell = env::var("SHELL").unwrap_or_else(|_| "unknown_shell".to_string()); + let shell_path = env::var("SHELL").unwrap_or_else(|_| "unknown_shell".to_string()); + let shell_name = shell_path.rsplit('/').next().unwrap_or("unknown_shell"); - Ok(shell) + Ok(shell_name.to_string()) } pub fn get_root_disk_usage() -> Result {