fix(history): respect zdotdir config (#83)

closes #82

Also added a `HISTFILE` so it always reads the correct file that the
shell is pointing to

Is there a `HISTFILE`? If so, use it
If it's Zsh: Is there a `ZDOTDIR`? Use `ZDOTDIR/.zsh_history`
If it's Fish: Is there an `XDG_DATA_HOME`? Use
`XDG_DATA_HOME/fish/fish_history`
If none of them are present, revert to the default `$HOME/...`
This commit is contained in:
VERSE
2026-07-31 15:12:49 +07:00
committed by GitHub
parent 9663788de6
commit e9e50c7dea
2 changed files with 19 additions and 7 deletions
+8
View File
@@ -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()