summaryrefslogtreecommitdiff
path: root/completions/ssh
diff options
context:
space:
mode:
authorDavid Paleino <dapal@debian.org>2011-11-03 12:32:52 +0100
committerDavid Paleino <dapal@debian.org>2011-11-03 12:32:52 +0100
commit2c8171c38d87ddef31c92a76547d3fdf773a1337 (patch)
tree5e720d5a06ead72ed55454bf6647a712a761ed91 /completions/ssh
parent9920a8faedf704420571d8072ccab27e9dac40ba (diff)
downloadbash-completion-2c8171c38d87ddef31c92a76547d3fdf773a1337.tar.gz
Imported Upstream version 1.90upstream/1.90
Diffstat (limited to 'completions/ssh')
-rw-r--r--completions/ssh132
1 files changed, 46 insertions, 86 deletions
diff --git a/completions/ssh b/completions/ssh
index cf966ae5..e30b9153 100644
--- a/completions/ssh
+++ b/completions/ssh
@@ -1,34 +1,22 @@
-# ssh(1) completion
-
-have ssh &&
-{
-
-_ssh_bindaddress()
-{
- COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \
- "$( PATH="$PATH:/sbin" ifconfig -a | \
- sed -ne 's/.*addr:\([^[:space:]]*\).*/\1/p' \
- -ne 's/.*inet[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p' )" \
- -- "$cur" ) )
-}
+# ssh(1) completion -*- shell-script -*-
_ssh_ciphers()
{
- COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W '3des-cbc aes128-cbc \
+ COMPREPLY+=( $( compgen -W '3des-cbc aes128-cbc \
aes192-cbc aes256-cbc aes128-ctr aes192-ctr aes256-ctr arcfour128 \
arcfour256 arcfour blowfish-cbc cast128-cbc' -- "$cur" ) )
}
_ssh_macs()
{
- COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W 'hmac-md5 hmac-sha1 \
+ COMPREPLY+=( $( compgen -W 'hmac-md5 hmac-sha1 \
umac-64@openssh.com hmac-ripemd160 hmac-sha1-96 hmac-md5-96' \
-- "$cur" ) )
}
_ssh_options()
{
- type compopt &>/dev/null && compopt -o nospace
+ compopt -o nospace
COMPREPLY=( $( compgen -S = -W 'AddressFamily BatchMode BindAddress \
ChallengeResponseAuthentication CheckHostIP Cipher Ciphers \
ClearAllForwardings Compression CompressionLevel ConnectionAttempts \
@@ -74,7 +62,7 @@ _ssh_suboption()
COMPREPLY=( $( compgen -W 'any inet inet6' -- "$cur" ) )
;;
BindAddress)
- _ssh_bindaddress
+ _ip_addresses
;;
Cipher)
COMPREPLY=( $( compgen -W 'blowfish des 3des' -- "$cur" ) )
@@ -116,13 +104,11 @@ _ssh_suboption_check()
_ssh()
{
- local cur prev configfile
- local -a config
+ local cur prev words cword
+ _init_completion -n : || return
- COMPREPLY=()
- _get_comp_words_by_ref -n : cur prev
- #cur=`_get_cword :`
- #prev=`_get_pword`
+ local configfile
+ local -a config
_ssh_suboption_check && return 0
@@ -152,7 +138,10 @@ _ssh()
return 0
;;
-b)
- _ssh_bindaddress
+ _ip_addresses
+ return 0
+ ;;
+ -D|-e|-I|-L|-O|-p|-R|-W)
return 0
;;
esac
@@ -164,12 +153,10 @@ _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 -- "${COMP_WORDS[@]}"
+ set -- "${words[@]}"
while [ $# -gt 0 ]; do
if [ "${1:0:2}" = -F ]; then
if [ ${#1} -gt 2 ]; then
@@ -183,29 +170,29 @@ _ssh()
shift
done
_known_hosts_real -a -F "$configfile" "$cur"
- if [ $COMP_CWORD -ne 1 ]; then
- _compopt_o_filenames
- COMPREPLY=( "${COMPREPLY[@]}" $( compgen -c -- "$cur" ) )
+ if [ $cword -ne 1 ]; then
+ compopt -o filenames
+ COMPREPLY+=( $( compgen -c -- "$cur" ) )
fi
fi
return 0
-}
+} &&
shopt -u hostcomplete && complete -F _ssh ssh slogin autossh
# sftp(1) completion
#
_sftp()
{
- local cur prev configfile
+ local cur prev words cword
+ _init_completion || return
- COMPREPLY=()
- _get_comp_words_by_ref cur prev
+ local configfile
_ssh_suboption_check && return 0
case $prev in
- -b|-F|-P)
+ -b|-F|-i)
_filedir
return 0
;;
@@ -213,6 +200,13 @@ _sftp()
_ssh_options
return 0
;;
+ -c)
+ _ssh_ciphers
+ return 0
+ ;;
+ -B|-D|-P|-R|-S|-s)
+ return 0
+ ;;
esac
if [[ "$cur" == -F* ]]; then
@@ -222,11 +216,10 @@ _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 -- "${COMP_WORDS[@]}"
+ set -- "${words[@]}"
while [ $# -gt 0 ]; do
if [ "${1:0:2}" = -F ]; then
if [ ${#1} -gt 2 ]; then
@@ -243,7 +236,7 @@ _sftp()
fi
return 0
-}
+} &&
shopt -u hostcomplete && complete -F _sftp sftp
# things we want to backslash escape in scp paths
@@ -283,7 +276,7 @@ _scp_remote_files()
sed -e 's/'$_scp_path_esc'/\\\\\\&/g' -e 's/[*@|=]$//g' \
-e 's/[^\/]$/& /g' )
fi
- COMPREPLY=( "${COMPREPLY[@]}" $files )
+ COMPREPLY+=( $files )
}
# This approach is used instead of _filedir to get a space appended
@@ -301,10 +294,10 @@ _scp_local_files()
fi
if $dirsonly ; then
- COMPREPLY=( "${COMPREPLY[@]}" $( command ls -aF1d $cur* 2>/dev/null | \
+ COMPREPLY+=( $( command ls -aF1d $cur* 2>/dev/null | \
sed -e "s/$_scp_path_esc/\\\\&/g" -e '/[^\/]$/d' -e "s/^/$1/") )
else
- COMPREPLY=( "${COMPREPLY[@]}" $( command ls -aF1d $cur* 2>/dev/null | \
+ COMPREPLY+=( $( command ls -aF1d $cur* 2>/dev/null | \
sed -e "s/$_scp_path_esc/\\\\&/g" -e 's/[*@|=]$//g' \
-e 's/[^\/]$/& /g' -e "s/^/$1/") )
fi
@@ -314,10 +307,10 @@ _scp_local_files()
#
_scp()
{
- local configfile cur prev prefix
+ local cur prev words cword
+ _init_completion -n : || return
- COMPREPLY=()
- _get_comp_words_by_ref -n : cur prev
+ local configfile prefix
_ssh_suboption_check && {
COMPREPLY=( "${COMPREPLY[@]/%/ }" )
@@ -330,7 +323,7 @@ _scp()
;;
-F|-i|-S)
_filedir
- type compopt &>/dev/null && compopt +o nospace
+ compopt +o nospace
return 0
;;
-c)
@@ -356,7 +349,7 @@ _scp()
prefix=-F
else
# Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument
- set -- "${COMP_WORDS[@]}"
+ set -- "${words[@]}"
while [ $# -gt 0 ]; do
if [ "${1:0:2}" = -F ]; then
if [ ${#1} -gt 2 ]; then
@@ -372,13 +365,13 @@ _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
;;
- */*)
- # pass through
+ */*|[.~]*)
+ # not a known host, pass through
;;
*)
_known_hosts_real -c -a -F "$configfile" "$cur"
@@ -389,40 +382,7 @@ _scp()
_scp_local_files "$prefix"
return 0
-}
+} &&
complete -F _scp -o nospace scp
-# ssh-copy-id(1) completion
-#
-_ssh_copy_id()
-{
- local cur prev
-
- COMPREPLY=()
- _get_comp_words_by_ref cur prev
-
- case $prev in
- -i)
- _filedir
- return 0
- ;;
- esac
-
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $( compgen -W '-i' -- "$cur" ) )
- else
- _known_hosts_real -a "$cur"
- fi
-
- return 0
-}
-complete -F _ssh_copy_id ssh-copy-id
-}
-
-# Local variables:
-# mode: shell-script
-# sh-basic-offset: 4
-# sh-indent-comment: t
-# indent-tabs-mode: nil
-# End:
# ex: ts=4 sw=4 et filetype=sh