Use scp remote/local completion functions in sshfs.
This commit is contained in:
parent
000cae95bc
commit
b6434541cc
2
CHANGES
2
CHANGES
@ -25,7 +25,7 @@ bash-completion (2.x)
|
||||
* Apply pine completion to alpine too.
|
||||
* Remove many unnecessary short option completions where long ones exist.
|
||||
* Improve chsh, configure, cvs, gkrellm, lftp, mdadm, modprobe, mplayer,
|
||||
mysqladmin, rsync, screen, service, scp, ssh, update-alternatives,
|
||||
mysqladmin, rsync, screen, service, scp, ssh, sshfs, update-alternatives,
|
||||
vncviewer, and general hostname completions.
|
||||
* Add abook and wtf completion, based on work by Raphaël Droz.
|
||||
* Add jarsigner, k3b, lftpget, pm-utils, pack200 and unpack200 completions.
|
||||
|
@ -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
|
||||
} &&
|
||||
|
Loading…
x
Reference in New Issue
Block a user