ssh, scp, sftp, ssh-copy-id: Use _parse_help/_parse_usage, add some option argument (non)completions.

This commit is contained in:
Ville Skyttä 2011-05-12 00:24:57 +03:00
parent 2e4d73ff6c
commit 68f7fa16b0

View File

@ -152,6 +152,9 @@ _ssh()
_ssh_bindaddress
return 0
;;
-D|-e|-I|-L|-O|-p|-R|-W)
return 0
;;
esac
if [[ "$cur" == -F* ]]; then
@ -161,9 +164,7 @@ _ssh()
COMPREPLY=( "${COMPREPLY[@]/#/-F}" )
cur=-F$cur # Restore cur
elif [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-1 -2 -4 -6 -A -a -C -f -g -K -k -M \
-N -n -q -s -T -t -V -v -X -v -Y -y -b -b -c -D -e -F \
-i -L -l -m -O -o -p -R -S -w' -- "$cur" ) )
COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) )
else
# Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument
set -- "${words[@]}"
@ -202,7 +203,7 @@ _sftp()
_ssh_suboption_check && return 0
case $prev in
-b|-F|-P)
-b|-F|-i)
_filedir
return 0
;;
@ -210,6 +211,13 @@ _sftp()
_ssh_options
return 0
;;
-c)
_ssh_ciphers
return 0
;;
-B|-D|-P|-R|-S|-s)
return 0
;;
esac
if [[ "$cur" == -F* ]]; then
@ -219,8 +227,7 @@ _sftp()
COMPREPLY=( "${COMPREPLY[@]/#/-F}" )
cur=-F$cur # Restore cur
elif [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-1 -C -v -B -b -F -o -P -R -S -s' \
-- "$cur" ) )
COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) )
else
# Search COMP_WORDS for '-F configfile' argument
set -- "${words[@]}"
@ -369,8 +376,8 @@ _scp()
case $cur in
-*)
COMPREPLY=( $( compgen -W '-1 -2 -4 -6 -B -C -c -F -i -l -o \
-P -p -q -r -S -v' -- "$cur" ) )
COMPREPLY=( $( compgen -W '$( _parse_usage "${words[0]}" )' \
-- "$cur" ) )
COMPREPLY=( "${COMPREPLY[@]/%/ }" )
return 0
;;
@ -404,7 +411,7 @@ _ssh_copy_id()
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-i' -- "$cur" ) )
COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) )
else
_known_hosts_real -a "$cur"
fi