From fbb0b604547d5c4703f7e76fb41e65a090811557 Mon Sep 17 00:00:00 2001 From: Yuki Ito Date: Mon, 8 Jan 2018 17:51:45 +0900 Subject: Add support for fish --- cmd/install/install.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'cmd/install/install.go') diff --git a/cmd/install/install.go b/cmd/install/install.go index 082a226..4a70624 100644 --- a/cmd/install/install.go +++ b/cmd/install/install.go @@ -68,9 +68,36 @@ func installers() (i []installer) { if f := rcFile(".zshrc"); f != "" { i = append(i, zsh{f}) } + if d := fishConfigDir(); d != "" { + i = append(i, fish{d}) + } return } +func fishConfigDir() string { + configDir := filepath.Join(getConfigHomePath(), "fish") + if configDir == "" { + return "" + } + if info, err := os.Stat(configDir); err != nil || !info.IsDir() { + return "" + } + return configDir +} + +func getConfigHomePath() string { + u, err := user.Current() + if err != nil { + return "" + } + + configHome := os.Getenv("XDG_CONFIG_HOME") + if configHome == "" { + return filepath.Join(u.HomeDir, ".config") + } + return configHome +} + func getBinaryPath() (string, error) { bin, err := os.Executable() if err != nil { -- cgit v1.2.3