diff options
author | Ville Skyttä <ville.skytta@iki.fi> | 2009-12-26 16:20:14 +0200 |
---|---|---|
committer | Ville Skyttä <ville.skytta@iki.fi> | 2009-12-26 16:20:14 +0200 |
commit | b6434541ccae0d24dae6d567ac3a7f6b72235c5e (patch) | |
tree | 4f575c4d5942687aa0a565872665f87c2511da73 /contrib | |
parent | 000cae95bc2c64692bd3fce1cfbe8ab1779580d6 (diff) | |
download | bash-completion-b6434541ccae0d24dae6d567ac3a7f6b72235c5e.tar.gz |
Use scp remote/local completion functions in sshfs.
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/sshfs | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/contrib/sshfs b/contrib/sshfs index 9301b635..78bf11d2 100644 --- a/contrib/sshfs +++ b/contrib/sshfs @@ -1,6 +1,6 @@ # sshfs(1) completion -have sshfs && have ssh && +have sshfs && _sshfs() { local cur userhost path @@ -10,36 +10,16 @@ _sshfs() _expand || return 0 - # things we want to backslash escape - local esc="[][(){}<>\",:;^&\!$=?\`|\\ ']" - - if [[ "$cur" == *:* ]]; then - local IFS=$'\t\n' - # remove backslash escape from the first colon - cur=${cur/\\:/:} - userhost=${cur%%?(\\):*} - path=${cur#*:} - # unescape (3 backslashes to 1 for chars we escaped) - path=$( sed -e 's/\\\\\\\('$esc'\)/\\\1/g' <<<"$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/'$esc'/\\\\\\&/g' -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) ) + if [[ "$cur" == *:* ]] && type _scp_remote_files &>/dev/null ; then + _scp_remote_files -d + # unlike scp and rsync, sshfs works with 1 backslash instead of 3 + COMPREPLY=( "${COMPREPLY[@]//\\\\\\/\\}" ) return 0 fi [[ "$cur" == */* ]] || _known_hosts_real -c -a "$cur" - # This approach is used instead of _filedir to get a space appended - # after local file/dir completions, and -o nospace retained for others. - local IFS=$'\t\n' - COMPREPLY=( "${COMPREPLY[@]}" $( command ls -aF1d $cur* 2>/dev/null | \ - sed -e "s/$esc/\\\\&/g" -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) ) + type _scp_local_files &>/dev/null && _scp_local_files -d return 0 } && |