From a71e7c6be72965afd537aae076e0aee9e6f0755e Mon Sep 17 00:00:00 2001 From: cramosc Date: Mon, 17 Mar 2025 03:23:40 +0100 Subject: feat: support HISTFILE to specify the bash/zsh history file (#1236) --- src/utils/command.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/utils/command.rs') diff --git a/src/utils/command.rs b/src/utils/command.rs index 3008028..300a471 100644 --- a/src/utils/command.rs +++ b/src/utils/command.rs @@ -183,8 +183,14 @@ pub fn append_to_shell_history(shell: &str, command: &str, exit_code: i32) -> io fn get_history_file(shell: &str) -> Option { match shell { - "bash" | "sh" => Some(home_dir()?.join(".bash_history")), - "zsh" => Some(home_dir()?.join(".zsh_history")), + "bash" | "sh" => env::var("HISTFILE") + .ok() + .map(PathBuf::from) + .or(Some(home_dir()?.join(".bash_history"))), + "zsh" => env::var("HISTFILE") + .ok() + .map(PathBuf::from) + .or(Some(home_dir()?.join(".zsh_history"))), "nushell" => Some(dirs::config_dir()?.join("nushell").join("history.txt")), "fish" => Some( home_dir()? -- cgit v1.2.3