From 00e44ed94b0e40345492bd513066ea2c50778c27 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sat, 8 Sep 2012 02:06:57 +0200 Subject: Move completion files to contrib. --- Makefile | 4 +- bash-completion/pass-bash-completion | 32 ---------------- bash-completion/pass-zsh-completion | 72 ------------------------------------ contrib/pass.bash-completion | 32 ++++++++++++++++ contrib/pass.zsh-completion | 72 ++++++++++++++++++++++++++++++++++++ 5 files changed, 106 insertions(+), 106 deletions(-) delete mode 100644 bash-completion/pass-bash-completion delete mode 100644 bash-completion/pass-zsh-completion create mode 100644 contrib/pass.bash-completion create mode 100644 contrib/pass.zsh-completion diff --git a/Makefile b/Makefile index e0485a8..e1c662f 100644 --- a/Makefile +++ b/Makefile @@ -13,9 +13,9 @@ install: @mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)/man1 $(DESTDIR)$(SYSCONFDIR)/bash_completion.d @install -m 0755 -v src/password-store.sh $(DESTDIR)$(BINDIR)/pass @install -m 0644 -v man/pass.1 $(DESTDIR)$(MANDIR)/man1/pass.1 - @install -m 0644 -v bash-completion/pass-bash-completion $(DESTDIR)$(SYSCONFDIR)/bash_completion.d/password-store + @install -m 0644 -v contrib/pass.bash-completion $(DESTDIR)$(SYSCONFDIR)/bash_completion.d/password-store # Uncomment to install the zsh completion file too. -# @install -m 0644 -v bash-completion/pass-zsh/completion $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_pass +# @install -m 0644 -v contrib/pass.zsh-completion $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_pass uninstall: @rm -vf $(DESTDIR)$(BINDIR)/pass $(DESTDIR)$(MANDIR)/man1/pass.1 $(DESTDIR)$(SYSCONFDIR)/bash_completion.d/password-store diff --git a/bash-completion/pass-bash-completion b/bash-completion/pass-bash-completion deleted file mode 100644 index 8ddc377..0000000 --- a/bash-completion/pass-bash-completion +++ /dev/null @@ -1,32 +0,0 @@ -# completion file for bash - -# (C) Copyright 2012 Jason A. Donenfeld . All Rights Reserved. -# This is released under the GPLv2+. Please see COPYING for more information. - -_pass() -{ - local cur prev prefix suffix gen - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" - prefix="$HOME/.password-store/" - suffix=".gpg" - - if [[ $prev == --* ]]; then - return 0 - fi - - for item in $(compgen -f $prefix$cur); do - if [[ $item == $prefix.* ]]; then - continue - fi - if [[ -d $item ]]; then - item="$item/" - fi - item="${item%$suffix}" - gen="$gen ${item#$prefix}" - done - - COMPREPLY=( $gen ) -} -complete -o filenames -o nospace -F _pass pass diff --git a/bash-completion/pass-zsh-completion b/bash-completion/pass-zsh-completion deleted file mode 100644 index bc23356..0000000 --- a/bash-completion/pass-zsh-completion +++ /dev/null @@ -1,72 +0,0 @@ -#compdef pass - -# This file is under the GPLv2+ license. -# Heavily based on http://zsh.sf.net/Guide/zshguide06.html#l177 -# And Frédéric Perrin article http://tar-jx.bz/notes/zsh-completion.html -# Johan Venant, September 2012 - - -_pass () { - local cmd - if (( CURRENT > 2)); then - cmd=${words[2]} - # Set the context for the subcommand. - curcontext="${curcontext%:*:*}:pass-$cmd" - # Narrow the range of words we are looking at to exclude `pass' - (( CURRENT-- )) - shift words - # Run the completion for the subcommand - (( $+functions[_pass_cmd_$cmd] )) && _pass_cmd_$cmd - - else - _values : \ - "init[Initialize new password storage]" \ - "ls[subfolder List names of passwords]" \ - "show[Decrypt and print a password]" \ - "insert[Insert a new password]" \ - "generate[Generate a new password using pwgen]" \ - "rm[Remove the password]" \ - "push[push the latest changes using git-push(1)]" \ - "pull[pull the latest changes using git-pull(1)]" \ - "git[Call git]" \ - "help[Help]" - fi -} - -_pass_cmd_init () { -} - -_pass_cmd_ls () { - _arguments : \ - '::ls:_get_stored_pwd' -} - -_pass_cmd_show () { - _arguments : \ - "-c[put it on the clipboard]" \ - '*::show:_get_stored_pwd' - #'::pass id:_files -W ~/.password-store -g "*.gpg(|.*)(-.)"' -} - -_pass_cmd_insert () { - _arguments : \ - "-n[no console output]" \ - "-m[multiline]" \ - '::show:_get_stored_pwd' -} - -_pass_cmd_generate () { - _arguments : \ - "-n[no symbols]" \ - "-c[put password on the clipboard]" \ - '::show:_get_stored_pwd' -} - -_pass_cmd_rm () { - _arguments : \ - '::ls:_get_stored_pwd' -} - -_get_stored_pwd () { - compadd `find ~/.password-store \( -name .git -o -name .gpg-id \) -prune -o -print | sed 's#.*/.password-store/\?##' | sed 's#\.gpg##' | sort` -} diff --git a/contrib/pass.bash-completion b/contrib/pass.bash-completion new file mode 100644 index 0000000..8ddc377 --- /dev/null +++ b/contrib/pass.bash-completion @@ -0,0 +1,32 @@ +# completion file for bash + +# (C) Copyright 2012 Jason A. Donenfeld . All Rights Reserved. +# This is released under the GPLv2+. Please see COPYING for more information. + +_pass() +{ + local cur prev prefix suffix gen + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + prefix="$HOME/.password-store/" + suffix=".gpg" + + if [[ $prev == --* ]]; then + return 0 + fi + + for item in $(compgen -f $prefix$cur); do + if [[ $item == $prefix.* ]]; then + continue + fi + if [[ -d $item ]]; then + item="$item/" + fi + item="${item%$suffix}" + gen="$gen ${item#$prefix}" + done + + COMPREPLY=( $gen ) +} +complete -o filenames -o nospace -F _pass pass diff --git a/contrib/pass.zsh-completion b/contrib/pass.zsh-completion new file mode 100644 index 0000000..bc23356 --- /dev/null +++ b/contrib/pass.zsh-completion @@ -0,0 +1,72 @@ +#compdef pass + +# This file is under the GPLv2+ license. +# Heavily based on http://zsh.sf.net/Guide/zshguide06.html#l177 +# And Frédéric Perrin article http://tar-jx.bz/notes/zsh-completion.html +# Johan Venant, September 2012 + + +_pass () { + local cmd + if (( CURRENT > 2)); then + cmd=${words[2]} + # Set the context for the subcommand. + curcontext="${curcontext%:*:*}:pass-$cmd" + # Narrow the range of words we are looking at to exclude `pass' + (( CURRENT-- )) + shift words + # Run the completion for the subcommand + (( $+functions[_pass_cmd_$cmd] )) && _pass_cmd_$cmd + + else + _values : \ + "init[Initialize new password storage]" \ + "ls[subfolder List names of passwords]" \ + "show[Decrypt and print a password]" \ + "insert[Insert a new password]" \ + "generate[Generate a new password using pwgen]" \ + "rm[Remove the password]" \ + "push[push the latest changes using git-push(1)]" \ + "pull[pull the latest changes using git-pull(1)]" \ + "git[Call git]" \ + "help[Help]" + fi +} + +_pass_cmd_init () { +} + +_pass_cmd_ls () { + _arguments : \ + '::ls:_get_stored_pwd' +} + +_pass_cmd_show () { + _arguments : \ + "-c[put it on the clipboard]" \ + '*::show:_get_stored_pwd' + #'::pass id:_files -W ~/.password-store -g "*.gpg(|.*)(-.)"' +} + +_pass_cmd_insert () { + _arguments : \ + "-n[no console output]" \ + "-m[multiline]" \ + '::show:_get_stored_pwd' +} + +_pass_cmd_generate () { + _arguments : \ + "-n[no symbols]" \ + "-c[put password on the clipboard]" \ + '::show:_get_stored_pwd' +} + +_pass_cmd_rm () { + _arguments : \ + '::ls:_get_stored_pwd' +} + +_get_stored_pwd () { + compadd `find ~/.password-store \( -name .git -o -name .gpg-id \) -prune -o -print | sed 's#.*/.password-store/\?##' | sed 's#\.gpg##' | sort` +} -- cgit v1.2.3