aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-11-16 14:07:39 -0200
committerSilvio Rhatto <rhatto@riseup.net>2013-11-16 14:07:39 -0200
commit7d5aea9198395255062c71f2695044a8f98fc891 (patch)
tree326bf086b090b6e355a4cb3605779462260a4508
parentbf99499751482886833ad7ce77930ba9a12b8a86 (diff)
downloadkeyringer-7d5aea9198395255062c71f2695044a8f98fc891.tar.gz
keyringer-7d5aea9198395255062c71f2695044a8f98fc891.tar.bz2
Misc enhancements
-rw-r--r--ChangeLog8
-rwxr-xr-xlib/keyringer/actions/ls7
-rw-r--r--lib/keyringer/completions/bash/keyringer10
-rw-r--r--lib/keyringer/completions/zsh/_keyringer3
-rwxr-xr-xlib/keyringer/functions2
5 files changed, 23 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index b55493d..d287171 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,10 @@
-2013-11-14 - Silvio Rhatto <rhatto@riseup.net>
+2013-11-16 - Silvio Rhatto <rhatto@riseup.net>
+
+ Shell completion enhancements.
+
+ Fixing keyringer_has_action() to correctly handle "/" and ".".
+
+ Action ls now supports leading slash ("/").
Support for encrypting a whole tree (closes #21)
diff --git a/lib/keyringer/actions/ls b/lib/keyringer/actions/ls
index ec8080b..61facc8 100755
--- a/lib/keyringer/actions/ls
+++ b/lib/keyringer/actions/ls
@@ -10,7 +10,10 @@ source "$LIB" || exit 1
# Aditional parameters
CWD="`pwd`"
-# Run list command
+# Avoid trailing slash
shift
-cd "$KEYDIR" && ls $*
+ARGS="`echo "$*" | sed -e "s|^/*||"`"
+
+# Run list command
+cd "$KEYDIR" && ls $ARGS
cd "$CWD"
diff --git a/lib/keyringer/completions/bash/keyringer b/lib/keyringer/completions/bash/keyringer
index 7bfa62f..88c85cf 100644
--- a/lib/keyringer/completions/bash/keyringer
+++ b/lib/keyringer/completions/bash/keyringer
@@ -46,11 +46,12 @@ _keyringer_git_complete() {
function _keyringer_path_complete() {
# Thanks http://unix.stackexchange.com/questions/55520/create-bash-completion-script-to-autocomplete-paths-after-is-equal-sign
cur=${1//\\ / }
- [[ ${cur} == "~/"* ]] && cur=${cur/\~/$HOME}
+ [[ ${cur} == "~"* ]] && cur=${cur/\~/$HOME}
echo ${cur}
}
+# Main completion
_keyringer() {
# Standard stuff
local cur prev command config path keyrings instances instance opts
@@ -94,6 +95,7 @@ _keyringer() {
opts="ls edit"
;;
ls|encrypt|encrypt-batch|decrypt|edit|append|append-batch|del|recrypt|open)
+ cur="`echo ${cur} | sed -e "s|^/*||"`" # avoid trailing slash
opts="$(bash -c "set -f && export KEYRINGER_CHECK_VERSION=false && keyringer $instance ls -p -d ${cur}*" 2> /dev/null)"
;;
genpair)
@@ -104,7 +106,7 @@ _keyringer() {
;;
init)
cur="$(_keyringer_path_complete ${cur})"
- opts="$(compgen -o dirnames ${cur})"
+ opts="`compgen -o default "${cur}"`"
;;
*)
;;
@@ -112,9 +114,11 @@ _keyringer() {
elif [ "${#COMP_WORDS[@]}" == "5" ]; then
case "${command}" in
recipients)
+ cur="`echo ${cur} | sed -e "s|^/*||"`" # avoid trailing slash
opts="$(cd $path/config/recipients && ls --color=never -p ${cur}* 2> /dev/null)"
;;
genpair)
+ cur="`echo ${cur} | sed -e "s|^/*||"`" # avoid trailing slash
opts="$(bash -c "set -f && export KEYRINGER_CHECK_VERSION=false && keyringer $instance ls -p -d ${cur}*" 2> /dev/null)"
;;
git)
@@ -123,7 +127,7 @@ _keyringer() {
;;
encrypt|encrypt-batch)
cur="$(_keyringer_path_complete ${cur})"
- opts="$(compgen -o dirnames ${cur})"
+ opts="`compgen -o default "${cur}"`"
;;
*)
;;
diff --git a/lib/keyringer/completions/zsh/_keyringer b/lib/keyringer/completions/zsh/_keyringer
index 50ff433..ac31879 100644
--- a/lib/keyringer/completions/zsh/_keyringer
+++ b/lib/keyringer/completions/zsh/_keyringer
@@ -51,6 +51,7 @@ _keyringer() {
compadd "$@" ls edit
;;
ls|encrypt|encrypt-batch|decrypt|edit|append|append-batch|del|recrypt|open)
+ words[4]="`echo $words[4] | sed -e "s|^/*||"`" # avoid trailing slash
compadd "$@" $(KEYRINGER_CHECK_VERSION=false keyringer $words[2] ls -p -d $words[4]'*' 2> /dev/null)
;;
genpair)
@@ -69,9 +70,11 @@ _keyringer() {
misc)
case "$words[3]" in
recipients)
+ words[5]="$(echo $words[5] | sed -e "s|^/||")" # TODO: avoid trailing slash
compadd "$@" $(cd $keyring_path/config/recipients && ls --color=never -p $words[5]'*' 2> /dev/null)
;;
genpair)
+ words[5]="$(echo $words[5] | sed -e "s|^/||")" # TODO: avoid trailing slash
compadd "$@" $(KEYRINGER_CHECK_VERSION=false keyringer $words[2] ls -p -d $words[5]'*' 2> /dev/null)
;;
git)
diff --git a/lib/keyringer/functions b/lib/keyringer/functions
index dd31676..7b96d6f 100755
--- a/lib/keyringer/functions
+++ b/lib/keyringer/functions
@@ -59,7 +59,7 @@ function keyringer_has_action {
exit 1
fi
- if [ -e "$ACTIONS/$1" ]; then
+ if [ -e "$ACTIONS/$1" ] && [ ! -d "$ACTIONS/$1" ]; then
true
else
false