diff --git a/integration/history.go b/integration/history.go index 6f82965..9b23230 100644 --- a/integration/history.go +++ b/integration/history.go @@ -66,13 +66,17 @@ func SearchHistory(query string, aliases map[string]string) ([]HistResult, error } var histFile string - switch shellName { - case "zsh": - histFile = filepath.Join(home, ".zsh_history") - case "fish": - histFile = filepath.Join(home, ".local", "share", "fish", "fish_history") - default: - histFile = filepath.Join(home, ".bash_history") + if envHist := os.Getenv("HISTFILE"); envHist != "" { + histFile = envHist + } else { + switch shellName { + case "zsh": + histFile = filepath.Join(shell.GetZshConfigDir(), ".zsh_history") + case "fish": + histFile = filepath.Join(shell.GetFishDataDir(), "fish_history") + default: + histFile = filepath.Join(home, ".bash_history") + } } if info, err := os.Stat(histFile); err == nil { diff --git a/integration/shell/adapter.go b/integration/shell/adapter.go index 01472ee..3da10be 100644 --- a/integration/shell/adapter.go +++ b/integration/shell/adapter.go @@ -125,6 +125,14 @@ func GetFishConfigDir() string { return filepath.Join(home, ".config", "fish") } +func GetFishDataDir() string { + if xdg := os.Getenv("XDG_DATA_HOME"); xdg != "" { + return filepath.Join(xdg, "fish") + } + home, _ := os.UserHomeDir() + return filepath.Join(home, ".local", "share", "fish") +} + func ScanPosixAliases(files []string) map[string]string { aliases := make(map[string]string) home, err := os.UserHomeDir()