From 8769aa6370cd6b4ebd7393c32519a04772f5bd29 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 3 Sep 2012 04:43:01 +0200 Subject: Make into a real project. --- bash-completion/pass-bash-completion.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 bash-completion/pass-bash-completion.sh (limited to 'bash-completion') diff --git a/bash-completion/pass-bash-completion.sh b/bash-completion/pass-bash-completion.sh new file mode 100644 index 0000000..f3d285a --- /dev/null +++ b/bash-completion/pass-bash-completion.sh @@ -0,0 +1,28 @@ +#!/bin/bash +_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 -- cgit v1.2.3