summaryrefslogtreecommitdiff
path: root/internal/install/zsh.go
diff options
context:
space:
mode:
authorEyal Posener <[email protected]>2019-11-19 05:16:51 +0200
committerEyal Posener <[email protected]>2019-11-19 05:17:52 +0200
commitc3bfbddfe6b4d133259ee84a9f0f93a7d1b0971e (patch)
treed19ec98986d382d17f040787fb9f851b0b97b6fd /internal/install/zsh.go
parentca6cedb61484d2a211c105900f663e355b13626a (diff)
Move install package back to project root
Diffstat (limited to 'internal/install/zsh.go')
-rw-r--r--internal/install/zsh.go44
1 files changed, 0 insertions, 44 deletions
diff --git a/internal/install/zsh.go b/internal/install/zsh.go
deleted file mode 100644
index 29950ab..0000000
--- a/internal/install/zsh.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package install
-
-import "fmt"
-
-// (un)install in zsh
-// basically adds/remove from .zshrc:
-//
-// autoload -U +X bashcompinit && bashcompinit"
-// complete -C </path/to/completion/command> <command>
-type zsh struct {
- rc string
-}
-
-func (z zsh) IsInstalled(cmd, bin string) bool {
- completeCmd := z.cmd(cmd, bin)
- return lineInFile(z.rc, completeCmd)
-}
-
-func (z zsh) Install(cmd, bin string) error {
- if z.IsInstalled(cmd, bin) {
- return fmt.Errorf("already installed in %s", z.rc)
- }
-
- completeCmd := z.cmd(cmd, bin)
- bashCompInit := "autoload -U +X bashcompinit && bashcompinit"
- if !lineInFile(z.rc, bashCompInit) {
- completeCmd = bashCompInit + "\n" + completeCmd
- }
-
- return appendToFile(z.rc, completeCmd)
-}
-
-func (z zsh) Uninstall(cmd, bin string) error {
- if !z.IsInstalled(cmd, bin) {
- return fmt.Errorf("does not installed in %s", z.rc)
- }
-
- completeCmd := z.cmd(cmd, bin)
- return removeFromFile(z.rc, completeCmd)
-}
-
-func (zsh) cmd(cmd, bin string) string {
- return fmt.Sprintf("complete -o nospace -C %s %s", bin, cmd)
-}