From c177965da5d4fbf3aed0d3e4f227572394b8d1bf Mon Sep 17 00:00:00 2001 From: James French Date: Tue, 21 May 2013 12:45:54 +0800 Subject: [PATCH] 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 --- share/completions/rsync.fish | 14 ++++++++++++++ share/completions/scp.fish | 8 ++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/share/completions/rsync.fish b/share/completions/rsync.fish index 5bffb4b6a..7ed1be82d 100644 --- a/share/completions/rsync.fish +++ b/share/completions/rsync.fish @@ -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 +) + +" diff --git a/share/completions/scp.fish b/share/completions/scp.fish index 5e92ebf60..104cf5211 100644 --- a/share/completions/scp.fish +++ b/share/completions/scp.fish @@ -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 ) "