aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-08-22 23:32:00 -0300
committerSilvio Rhatto <rhatto@riseup.net>2013-08-22 23:32:00 -0300
commite4166898f016fc2eb4e625bd1e95f5736ec6226b (patch)
tree445671c7a0e8546d817fe2cd2c42672606f62e01 /lib
parent1a245c4d49852b8f861f2f48d3c066749abc37fa (diff)
downloadkeyringer-e4166898f016fc2eb4e625bd1e95f5736ec6226b.tar.gz
keyringer-e4166898f016fc2eb4e625bd1e95f5736ec6226b.tar.bz2
Use a different _keyringer_git_complete() for zsh
Diffstat (limited to 'lib')
-rw-r--r--lib/keyringer/completions/bash/keyringer1
-rw-r--r--lib/keyringer/completions/zsh/_keyringer36
2 files changed, 10 insertions, 27 deletions
diff --git a/lib/keyringer/completions/bash/keyringer b/lib/keyringer/completions/bash/keyringer
index 8317857..e33977a 100644
--- a/lib/keyringer/completions/bash/keyringer
+++ b/lib/keyringer/completions/bash/keyringer
@@ -7,7 +7,6 @@ if [[ -n ${ZSH_VERSION-} ]]; then
autoload -U +X bashcompinit && bashcompinit
fi
-# TODO: this is common completion code
# Completion for git subcommand
_keyringer_git_complete() {
if [ -e "/etc/bash_completion.d/git" ]; then
diff --git a/lib/keyringer/completions/zsh/_keyringer b/lib/keyringer/completions/zsh/_keyringer
index 390a783..dd8775c 100644
--- a/lib/keyringer/completions/zsh/_keyringer
+++ b/lib/keyringer/completions/zsh/_keyringer
@@ -1,31 +1,13 @@
#compdef keyringer
-# TODO: this is common completion code
+# TODO: how to call _git() properly?
# Completion for git subcommand
_keyringer_git_complete() {
- if [ -e "/etc/bash_completion.d/git" ]; then
- (
- source /etc/bash_completion.d/git
- cd $path
- COMP_WORDS=(git $*)
- COMP_CWORD=$((${#COMP_WORDS[*]} - 1))
-
- if [ "$COMP_CWORD" == "0" ]; then
- COMP_CWORD=1
- fi
-
- _git
-
- LAST=${COMP_WORDS[COMP_CWORD]}
- REPLY=${COMPREPLY[@]}
-
- if [ "$REPLY" == "$LAST" ]; then
- return
- fi
-
- echo ${COMPREPLY[@]}
- )
- fi
+ (
+ local CURRENT=1
+ local words=($*)
+ echo `_git`
+ )
}
_keyringer() {
@@ -42,6 +24,8 @@ _keyringer() {
# Process config
local keyrings="`ls $config | sed -e 's/config//'`"
+ source $config/config
+ keyring_path="`eval echo '$'$words[2]`"
_arguments \
'1: :->keyring' \
@@ -82,11 +66,11 @@ _keyringer() {
misc)
case "$words[3]" in
recipients)
- compadd "$@" $(cd $path/config/recipients && ls -p $words[5]* 2> /dev/null)
+ compadd "$@" $(cd $keyring_path/config/recipients && ls -p $words[5]* 2> /dev/null)
;;
genpair)
# TODO: do not rely on bash
- compadd "$@" $(bash -c "set -f && keyringer $instance ls -p -d $words[5]*" 2> /dev/null)
+ compadd "$@" $(bash -c "set -f && keyringer $words[2] ls -p -d $words[5]*" 2> /dev/null)
;;
git)
# TODO