diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2019-03-25 21:40:46 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2019-03-25 21:40:46 -0300 |
commit | d0ca362669eda64d6eaf8317672be47e7b310a83 (patch) | |
tree | 711d77b1c10405962abd0f4b72c9f37324720f63 | |
parent | acee5c1891fc0a6dec6183fadad52e0d136c95f4 (diff) | |
download | utils-ssh-d0ca362669eda64d6eaf8317672be47e7b310a83.tar.gz utils-ssh-d0ca362669eda64d6eaf8317672be47e7b310a83.tar.bz2 |
Pretty printing
-rwxr-xr-x | ssh-agent-loadkey-menu | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/ssh-agent-loadkey-menu b/ssh-agent-loadkey-menu index 29a8e6d..a335561 100755 --- a/ssh-agent-loadkey-menu +++ b/ssh-agent-loadkey-menu @@ -15,7 +15,13 @@ fi # Get available keys function __query { - ( cd $KEYS && find -name '*.pub' | sed -e 's/.pub$//' | grep -v decomissioned ) + ( + cd $KEYS && find -name '*.pub' | sed -e 's/.pub$//' | grep -v decomissioned | while read line; do + handle="`echo $line | cut -d '/' -f 3`" + type="`echo $line | cut -d '/' -f 2`" + echo "$handle ($type)" + done + ) } # List available keys @@ -30,19 +36,26 @@ function __list { # Display the keys available in the agent function __loaded { - echo "Current loaded keys:" - echo "" + #ssh-add -L | cut -d ' ' -f 3 | sed -e 's/^/\t/' - ssh-add -L | cut -d ' ' -f 3 | sed -e 's/^/\t/' + ssh-add -L | while read line; do + handle="$(basename `echo $line | cut -d ' ' -f 3`)" + type="`echo $line | cut -d ' ' -f 1 | sed -e 's/^ssh-//'`" + echo "$handle ($type)" + done | column -t -c 6 } # Key chooser mennu function __chooser { + echo "Usage: $BASENAME <keytype> <handle>" + echo "" echo "Available keys" echo "" __list | sed -e 's/^/\t/' echo "" - __loaded + echo "Current loaded keys:" + echo "" + __loaded | sed -e 's/^/\t/' echo "" read -rep "Choose key: " n @@ -59,7 +72,9 @@ function __chooser { # Load a key function __load { - KEY="$KEYS/$1" + HANDLE="$1" + TYPE="`echo $2 | sed -e 's/(//' -e 's/)//'`" + KEY="$KEYS/$TYPE/$HANDLE" # Check if the selected option has a custom procedure (monkeysphere, keyringer, etc) if [ -x "$KEY.askpass" ]; then @@ -71,4 +86,8 @@ function __load { } # Dispatch -__chooser +if [ ! -z "$2" ]; then + __load $* +else + __chooser +fi |