summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVille Skyttä <ville.skytta@iki.fi>2009-12-25 11:57:33 +0200
committerVille Skyttä <ville.skytta@iki.fi>2009-12-25 11:57:33 +0200
commit894c8778273272c754e50e8fd097d27eb00fdff3 (patch)
treee36da273cdc220005268904a1467c1d59e6ee161
parente0acaf8ed285da180d9320759a734b4ce9d5a7fb (diff)
downloadbash-completion-894c8778273272c754e50e8fd097d27eb00fdff3.tar.gz
Add scp option completion.
-rw-r--r--contrib/ssh43
1 files changed, 41 insertions, 2 deletions
diff --git a/contrib/ssh b/contrib/ssh
index ca11b710..a8950a20 100644
--- a/contrib/ssh
+++ b/contrib/ssh
@@ -248,10 +248,36 @@ shopt -u hostcomplete && complete -F _sftp sftp
#
_scp()
{
- local configfile cur userhost path prefix
+ local configfile cur prev userhost path prefix
COMPREPLY=()
cur=`_get_cword ":"`
+ prev=`_get_pword ":"`
+
+ _ssh_suboption_check && {
+ COMPREPLY=( "${COMPREPLY[@]/%/ }" )
+ return 0
+ }
+
+ case "$prev" in
+ -l|-P)
+ return 0
+ ;;
+ -F|-i|-S)
+ _filedir
+ type compopt &>/dev/null && compopt +o nospace
+ return 0
+ ;;
+ -c)
+ _ssh_ciphers
+ COMPREPLY=( "${COMPREPLY[@]/%/ }" )
+ return 0
+ ;;
+ -o)
+ _ssh_options
+ return 0
+ ;;
+ esac
_expand || return 0
@@ -297,7 +323,20 @@ _scp()
shift
done
- [[ "$cur" == */* ]] || _known_hosts_real -c -a -F "$configfile" "$cur"
+ 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=( "${COMPREPLY[@]/%/ }" )
+ return 0
+ ;;
+ */*)
+ # pass through
+ ;;
+ *)
+ _known_hosts_real -c -a -F "$configfile" "$cur"
+ ;;
+ esac
fi
# This approach is used instead of _filedir to get a space appended