Skip to content

Commit

Permalink
Add basic completion for fish
Browse files Browse the repository at this point in the history
This is a subset of tadfisher#151, only implementing the most relevant completion
(see tadfisher#118), i.e. completing password names.
  • Loading branch information
Milan Oberkirch committed Jan 6, 2024
1 parent a364d2a commit b473a24
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LIBDIR ?= $(PREFIX)/lib
SYSTEM_EXTENSION_DIR ?= $(LIBDIR)/password-store/extensions
MANDIR ?= $(PREFIX)/man
BASHCOMPDIR ?= /etc/bash_completion.d
FISHCOMPDIR ?= $(shell pkg-config --variable completionsdir fish || echo "/usr/share/fish/vendor_completions.d/")

all:
@echo "pass-$(PROG) is a shell script and does not need compilation, it can be simply executed."
Expand All @@ -20,6 +21,8 @@ install:
install -m0755 $(PROG).bash "$(DESTDIR)$(SYSTEM_EXTENSION_DIR)/$(PROG).bash"
install -d "$(DESTDIR)$(BASHCOMPDIR)/"
install -m 644 pass-otp.bash.completion "$(DESTDIR)$(BASHCOMPDIR)/pass-otp"
install -d "$(DESTDIR)$(FISHCOMPDIR)/"
install -m 644 pass-otp.fish.completion "$(DESTDIR)$(FISHCOMPDIR)/pass-otp.fish"
@echo
@echo "pass-$(PROG) is installed succesfully"
@echo
Expand Down
7 changes: 7 additions & 0 deletions pass-otp.fish.completion
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env fish

source "/usr/share/fish/vendor_completions.d/pass.fish"

complete -c $PROG -f -n '__fish_pass_needs_command' -a otp -d 'Command: Generate an OTP code'
complete -c $PROG -f -n '__fish_pass_uses_command otp' -s c -l clip -d 'Put otp code in clipboard'
complete -c $PROG -f -n '__fish_pass_uses_command otp' -a "(__fish_pass_print_entries)"

0 comments on commit b473a24

Please sign in to comment.