Rsync Remote Path Completion

Relevant section lifted from scp.fish
Silenced SSH output to squash banners and failed connections
Erroneous 'and true' removed
echo (commandline -ct) is exactly the same as commandline -ct
This commit is contained in:
James French 2013-05-21 12:45:54 +08:00 committed by David Adam (zanchey)
parent 220e1e8fb5
commit c177965da5
2 changed files with 18 additions and 4 deletions

View File

@ -104,3 +104,17 @@ complete -c rsync -s 6 -l ipv6 --description "Prefer IPv6"
complete -c rsync -l version --description "Display version and exit"
complete -c rsync -l help --description "Display help and exit"
#
# Remote path
#
complete -c rsync -d "Remote Path" -n "commandline -ct|sgrep -o '.*:'" -a "
(
#Prepend any user@host information supplied before the remote completion
commandline -ct|sgrep -o '.*:'
)(
#Get the list of remote files from the specified ssh server
ssh -o \"BatchMode yes\" (commandline -ct|sed -ne 's/\(.*\):.*/\1/p') ls\ -dp\ (commandline -ct|sed -ne 's/.*://p')\* 2> /dev/null
)
"

View File

@ -17,7 +17,7 @@ complete -c scp -d Hostname -a "
(
#Prepend any username specified in the completion to the hostname
echo (commandline -ct)|sed -ne 's/\(.*@\).*/\1/p'
commandline -ct |sed -ne 's/\(.*@\).*/\1/p'
)(
cat ~/.ssh/known_hosts{,2} ^/dev/null|cut -d ' ' -f 1| cut -d , -f 1
):
@ -29,14 +29,14 @@ complete -c scp -d Hostname -a "
#
# Remote path
#
complete -c scp -d "Remote Path" -n "echo (commandline -ct)|sgrep -o '.*:';and true" -a "
complete -c scp -d "Remote Path" -n "commandline -ct|sgrep -o '.*:'" -a "
(
#Prepend any user@host information supplied before the remote completion
echo (commandline -ct)|sgrep -o '.*:'
commandline -ct|sgrep -o '.*:'
)(
#Get the list of remote files from the specified ssh server
ssh -o \"BatchMode yes\" (echo (commandline -ct)|sed -ne 's/\(.*\):.*/\1/p') ls\ -dp\ (echo (commandline -ct)|sed -ne 's/.*://p')\*
ssh -o \"BatchMode yes\" (commandline -ct|sed -ne 's/\(.*\):.*/\1/p') ls\ -dp\ (commandline -ct|sed -ne 's/.*://p')\* 2> /dev/null
)
"