diff options
| author | cramosc <cramosc@users.noreply.github.com> | 2025-03-17 03:23:40 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-17 10:23:40 +0800 |
| commit | a71e7c6be72965afd537aae076e0aee9e6f0755e (patch) | |
| tree | 762b403f7dac6b741e46c5efca21ddf538e3c891 | |
| parent | 12246c6d27edde1d6ea8aa684248e33890caef86 (diff) | |
| download | aichat-a71e7c6be72965afd537aae076e0aee9e6f0755e.tar.gz | |
feat: support HISTFILE to specify the bash/zsh history file (#1236)
| -rw-r--r-- | src/utils/command.rs | 10 |
1 files changed, 8 insertions, 2 deletions
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<PathBuf> { 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()? |
