split _known_hosts into _kwnown_hosts and _known_hosts_real, instead of using an option to set current word
This commit is contained in:
parent
ae757e453b
commit
d5fd1c3412
@ -2703,29 +2703,32 @@ shopt -u hostcomplete && complete -F _user_at_host $nospace talk ytalk finger
|
||||
# -F configfile Use `configfile' for configuration settings
|
||||
# -h host Complete on given host
|
||||
_known_hosts()
|
||||
{
|
||||
local cur
|
||||
|
||||
COMPREPLY=()
|
||||
cur=`_get_cword`
|
||||
|
||||
_known_hosts_real $@
|
||||
}
|
||||
|
||||
_known_hosts_real()
|
||||
{
|
||||
local configfile
|
||||
local cur curd ocur user suffix aliases global_kh user_kh hosts i host
|
||||
local curd ocur user suffix aliases global_kh user_kh hosts i host
|
||||
local -a kh khd config
|
||||
local IFS=$'\n'
|
||||
|
||||
local OPTIND=1
|
||||
local cur_set=0
|
||||
while getopts "acF:h:" flag "$@"; do
|
||||
while getopts "acF:" flag "$@"; do
|
||||
case $flag in
|
||||
a) aliases='yes' ;;
|
||||
c) suffix=':' ;;
|
||||
F) configfile="$OPTARG" ;;
|
||||
h) cur="$OPTARG"; cur_set=1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
COMPREPLY=()
|
||||
if [ $cur_set = 0 ]; then
|
||||
cur=`_get_cword`
|
||||
fi
|
||||
ocur=$cur
|
||||
|
||||
|
||||
[[ $cur == *@* ]] && user=${cur%@*}@ && cur=${cur#*@}
|
||||
kh=()
|
||||
|
@ -95,7 +95,7 @@ _ssh()
|
||||
fi
|
||||
shift
|
||||
done
|
||||
_known_hosts -a "$optconfigfile"
|
||||
_known_hosts_real -a "$optconfigfile"
|
||||
else
|
||||
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -c -- $cur ) )
|
||||
fi
|
||||
@ -145,7 +145,7 @@ _sftp()
|
||||
fi
|
||||
shift
|
||||
done
|
||||
_known_hosts -a "$optconfigfile"
|
||||
_known_hosts_real -a "$optconfigfile"
|
||||
fi
|
||||
|
||||
return 0
|
||||
@ -201,7 +201,7 @@ _scp()
|
||||
shift
|
||||
done
|
||||
|
||||
[[ "$cur" == */* ]] || _known_hosts -c -a "$optconfigfile"
|
||||
[[ "$cur" == */* ]] || _known_hosts_real -c -a "$optconfigfile"
|
||||
|
||||
# This approach is used instead of _filedir to get a space appended
|
||||
# after local file/dir completions, and $nospace retained for others.
|
||||
@ -234,7 +234,7 @@ _ssh_copy_id() {
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '-i' -- $cur ) )
|
||||
else
|
||||
_known_hosts -a
|
||||
_known_hosts_real -a
|
||||
fi
|
||||
|
||||
return 0
|
||||
|
@ -12,20 +12,20 @@ _xhost ()
|
||||
case "$cur" in
|
||||
+*)
|
||||
cur=${cur:1}
|
||||
_known_hosts -h "$cur"
|
||||
_known_hosts_real
|
||||
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
|
||||
COMPREPLY[i]=+${COMPREPLY[i]}
|
||||
done
|
||||
;;
|
||||
-*)
|
||||
cur=${cur:1}
|
||||
_known_hosts -h "$cur"
|
||||
_known_hosts_real
|
||||
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
|
||||
COMPREPLY[i]=-${COMPREPLY[i]}
|
||||
done
|
||||
;;
|
||||
*)
|
||||
_known_hosts -h "$cur"
|
||||
_known_hosts_real
|
||||
;;
|
||||
esac
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user