From b3ad6561fa41e6af3cd419ca84713593fe957219 Mon Sep 17 00:00:00 2001 From: ianmacd <> Date: Fri, 15 Mar 2002 06:20:04 +0000 Subject: [PATCH] - _scp(): try to perform remote path completion when parameter contains a colon. This is subject to usual bash trailing whitespace issue. --- bash_completion | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/bash_completion b/bash_completion index ed626049..cd90ea27 100644 --- a/bash_completion +++ b/bash_completion @@ -1,6 +1,6 @@ # bash_completion - some programmable completion functions for bash 2.05a # -# $Id: bash_completion,v 1.197 2002/03/14 18:27:13 ianmacd Exp $ +# $Id: bash_completion,v 1.198 2002/03/15 07:20:04 ianmacd Exp $ # # Copyright (C) Ian Macdonald # @@ -310,7 +310,6 @@ complete -F _umount -o filenames umount # that instead. # _mount() - { local cur i sm COMPREPLY=() @@ -1380,13 +1379,28 @@ _ssh() have scp && _scp() { - local cur + local cur userhost path COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} _expand || return 0 + if [[ "$cur" == *:* ]]; then + # remove backslash escape from : + cur=${cur/\\:/:} + userhost=${cur%%?(\\):*} + path=${cur#*:} + if [ -z "$path" ]; then + # default to home dir of specified user on remote host + path=$( ssh -o 'Batchmode yes' $userhost pwd ) + fi + COMPREPLY=( $( compgen -P "$userhost:" \ + -W "`echo $( ssh -o 'Batchmode yes' $userhost \ + compgen -f -- $path )`" ) ) + return 0 + fi + [[ "$cur" == */* ]] || _known_hosts -c _filedir @@ -1394,7 +1408,6 @@ _scp() } [ "$have" ] && complete -o filenames -F _scp scp - # Linux route(8) completion. This could be improved by adding address family # completion for -A, etc. #