add a new -h flag, to set current word from calling function: it avoid parsing command twice, and also allows pre-processing it needed, as in xhost completion
This commit is contained in:
parent
4692a4b14a
commit
6f3d3be0ec
@ -2701,6 +2701,7 @@ shopt -u hostcomplete && complete -F _user_at_host $nospace talk ytalk finger
|
|||||||
# Arguments: -a Use aliases
|
# Arguments: -a Use aliases
|
||||||
# -c Use `:' suffix
|
# -c Use `:' suffix
|
||||||
# -F configfile Use `configfile' for configuration settings
|
# -F configfile Use `configfile' for configuration settings
|
||||||
|
# -h host Complete on given host
|
||||||
_known_hosts()
|
_known_hosts()
|
||||||
{
|
{
|
||||||
local configfile
|
local configfile
|
||||||
@ -2708,18 +2709,23 @@ _known_hosts()
|
|||||||
local -a kh khd config
|
local -a kh khd config
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
|
|
||||||
COMPREPLY=()
|
|
||||||
cur=`_get_cword`
|
|
||||||
ocur=$cur
|
|
||||||
|
|
||||||
local OPTIND=1
|
local OPTIND=1
|
||||||
while getopts "acF:" flag "$@"; do
|
local cur_set=0
|
||||||
|
while getopts "acF:h:" flag "$@"; do
|
||||||
case $flag in
|
case $flag in
|
||||||
a) aliases='yes' ;;
|
a) aliases='yes' ;;
|
||||||
c) suffix=':' ;;
|
c) suffix=':' ;;
|
||||||
F) configfile="$OPTARG" ;;
|
F) configfile="$OPTARG" ;;
|
||||||
|
h) cur="$OPTARG"; cur_set=1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
COMPREPLY=()
|
||||||
|
if [ $cur_set = 0 ]; then
|
||||||
|
cur=`_get_cword`
|
||||||
|
fi
|
||||||
|
ocur=$cur
|
||||||
|
|
||||||
|
|
||||||
[[ $cur == *@* ]] && user=${cur%@*}@ && cur=${cur#*@}
|
[[ $cur == *@* ]] && user=${cur%@*}@ && cur=${cur#*@}
|
||||||
kh=()
|
kh=()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user