[Bash-completion-commits] ./current r1189: Moved ssh completion to separate file.
David Paleino
d.paleino at gmail.com
Sat Sep 27 10:58:42 UTC 2008
------------------------------------------------------------
revno: 1189
committer: David Paleino <d.paleino at gmail.com>
branch nick: current
timestamp: Sat 2008-09-27 12:58:42 +0200
message:
Moved ssh completion to separate file.
added:
contrib/ssh
modified:
bash_completion
-------------- next part --------------
=== modified file 'bash_completion'
--- a/bash_completion 2008-09-27 10:28:09 +0000
+++ b/bash_completion 2008-09-27 10:58:42 +0000
@@ -2624,107 +2624,6 @@
complete -F _known_hosts traceroute traceroute6 tracepath tracepath6 \
ping ping6 fping fping6 telnet host nslookup rsh rlogin ftp dig ssh-installkeys mtr
-# ssh(1) completion
-#
-have ssh && {
-_ssh()
-{
- local cur prev
- local -a config
-
- COMPREPLY=()
- cur=`_get_cword`
- prev=${COMP_WORDS[COMP_CWORD-1]}
-
- case "$prev" in
- -*c)
- COMPREPLY=( $( compgen -W 'blowfish 3des 3des-cbc blowfish-cbc \
- arcfour cast128-cbc' -- $cur ) )
- ;;
- -*i)
- _filedir
- ;;
- -*l)
- COMPREPLY=( $( compgen -u -- $cur ) )
- ;;
- *)
- _known_hosts -a
-
- [ $COMP_CWORD -eq 1 ] || \
- COMPREPLY=( "${COMPREPLY[@]}" $( compgen -c -- $cur ) )
- esac
-
- return 0
-}
-shopt -u hostcomplete && complete -F _ssh ssh slogin sftp xhost autossh
-
-# scp(1) completion
-#
-_scp()
-{
- local cur userhost path
-
- COMPREPLY=()
- cur=`_get_cword ":"`
-
- _expand || return 0
-
- if [[ "$cur" == *:* ]]; then
- local IFS=$'\t\n'
- # remove backslash escape from :
- cur=${cur/\\:/:}
- userhost=${cur%%?(\\):*}
- path=${cur#*:}
- # unescape spaces
- path=${path//\\\\\\\\ / }
- if [ -z "$path" ]; then
- # default to home dir of specified user on remote host
- path=$(ssh -o 'Batchmode yes' $userhost pwd 2>/dev/null)
- fi
- # escape spaces; remove executables, aliases, pipes and sockets;
- # add space at end of file names
- COMPREPLY=( $( ssh -o 'Batchmode yes' $userhost \
- command ls -aF1d "$path*" 2>/dev/null | \
- sed -e "s/[][(){}<>\",:;^&!$&=?\`|\\ ']/\\\\\\\\\\\\&/g" \
- -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
- return 0
- fi
-
- [[ "$cur" == */* ]] || _known_hosts -c -a
- local IFS=$'\t\n'
- COMPREPLY=( "${COMPREPLY[@]}" $( command ls -aF1d $cur* \
- 2>/dev/null | sed \
- -e "s/[][(){}<>\",:;^&!$&=?\`|\\ ']/\\\\&/g" \
- -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
- return 0
-}
-complete -F _scp $nospace scp
-
-# ssh-copy-id(1) completion
-#
-_ssh-copy-id() {
- local cur prev
-
- COMPREPLY=()
- cur=`_get_cword`
- prev=${COMP_WORDS[COMP_CWORD-1]}
-
- case "$prev" in
- -*i)
- _filedir
- ;;
- *)
- _known_hosts -a
-
- [ $COMP_CWORD -eq 1 ] || \
- COMPREPLY=( "${COMPREPLY[@]}" $( compgen -- $cur ) )
- esac
-
- return 0
-}
-complete -F _ssh-copy-id $filenames ssh-copy-id
-}
-
# rsync(1) completion
#
have rsync &&
=== added file 'contrib/ssh'
--- a/contrib/ssh 1970-01-01 00:00:00 +0000
+++ b/contrib/ssh 2008-09-27 10:58:42 +0000
@@ -0,0 +1,100 @@
+# ssh(1) completion
+#
+have ssh && {
+_ssh()
+{
+ local cur prev
+ local -a config
+
+ COMPREPLY=()
+ cur=`_get_cword`
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ case "$prev" in
+ -*c)
+ COMPREPLY=( $( compgen -W 'blowfish 3des 3des-cbc blowfish-cbc \
+ arcfour cast128-cbc' -- $cur ) )
+ ;;
+ -*i)
+ _filedir
+ ;;
+ -*l)
+ COMPREPLY=( $( compgen -u -- $cur ) )
+ ;;
+ *)
+ _known_hosts -a
+
+ [ $COMP_CWORD -eq 1 ] || \
+ COMPREPLY=( "${COMPREPLY[@]}" $( compgen -c -- $cur ) )
+ esac
+
+ return 0
+}
+shopt -u hostcomplete && complete -F _ssh ssh slogin sftp xhost autossh
+
+# scp(1) completion
+#
+_scp()
+{
+ local cur userhost path
+
+ COMPREPLY=()
+ cur=`_get_cword ":"`
+
+ _expand || return 0
+
+ if [[ "$cur" == *:* ]]; then
+ local IFS=$'\t\n'
+ # remove backslash escape from :
+ cur=${cur/\\:/:}
+ userhost=${cur%%?(\\):*}
+ path=${cur#*:}
+ # unescape spaces
+ path=${path//\\\\\\\\ / }
+ if [ -z "$path" ]; then
+ # default to home dir of specified user on remote host
+ path=$(ssh -o 'Batchmode yes' $userhost pwd 2>/dev/null)
+ fi
+ # escape spaces; remove executables, aliases, pipes and sockets;
+ # add space at end of file names
+ COMPREPLY=( $( ssh -o 'Batchmode yes' $userhost \
+ command ls -aF1d "$path*" 2>/dev/null | \
+ sed -e "s/[][(){}<>\",:;^&!$&=?\`|\\ ']/\\\\\\\\\\\\&/g" \
+ -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
+ return 0
+ fi
+
+ [[ "$cur" == */* ]] || _known_hosts -c -a
+ local IFS=$'\t\n'
+ COMPREPLY=( "${COMPREPLY[@]}" $( command ls -aF1d $cur* \
+ 2>/dev/null | sed \
+ -e "s/[][(){}<>\",:;^&!$&=?\`|\\ ']/\\\\&/g" \
+ -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
+ return 0
+}
+complete -F _scp $nospace scp
+
+# ssh-copy-id(1) completion
+#
+_ssh-copy-id() {
+ local cur prev
+
+ COMPREPLY=()
+ cur=`_get_cword`
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ case "$prev" in
+ -*i)
+ _filedir
+ ;;
+ *)
+ _known_hosts -a
+
+ [ $COMP_CWORD -eq 1 ] || \
+ COMPREPLY=( "${COMPREPLY[@]}" $( compgen -- $cur ) )
+ esac
+
+ return 0
+}
+complete -F _ssh-copy-id $filenames ssh-copy-id
+}
\ No newline at end of file
More information about the Bash-completion-commits
mailing list