Skip to content

Commit

Permalink
Make shell completion depend on binary name (gopasspw#536)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikschulz authored Dec 19, 2017
1 parent c7cf32b commit 1612b0a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions action/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ func (s *Action) CompletionBash(c *cli.Context) error {
return 0
}
complete -F _gopass_bash_autocomplete gopass
`
out += "complete -F _gopass_bash_autocomplete " + s.Name
fmt.Println(out)

return nil
Expand All @@ -55,8 +55,8 @@ func (s *Action) CompletionZSH(c *cli.Context) error {
out := `autoload -U compinit && compinit
autoload -U bashcompinit && bashcompinit
source <(gopass completion bash)
`
out += "source <(" + s.Name + " completion bash)"
fmt.Println(out)

return nil
Expand Down
5 changes: 4 additions & 1 deletion tests/completion_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tests

import (
"runtime"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -26,6 +27,7 @@ func TestCompletion(t *testing.T) {
}
complete -F _gopass_bash_autocomplete gopass`
bash += "-" + runtime.GOOS + "-" + runtime.GOARCH

out, err = ts.run("completion bash")
assert.NoError(t, err)
Expand All @@ -34,7 +36,8 @@ complete -F _gopass_bash_autocomplete gopass`
zsh := `autoload -U compinit && compinit
autoload -U bashcompinit && bashcompinit
source <(gopass completion bash)`
`
zsh += "source <(gopass-" + runtime.GOOS + "-" + runtime.GOARCH + " completion bash)"

out, err = ts.run("completion zsh")
assert.NoError(t, err)
Expand Down

0 comments on commit 1612b0a

Please sign in to comment.