[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 4fce53700073a9d65ebd20ac5756068fae32bc38
Guillaume Rousse
guillomovitch at zarb.org
Tue May 5 20:49:35 UTC 2009
The following commit has been merged in the master branch:
commit 6f3d3be0ec5a10d2ecfa584b2f33b1d6116d2a74
Author: Guillaume Rousse <guillomovitch at zarb.org>
Date: Sat May 2 17:13:07 2009 +0200
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
diff --git a/bash_completion b/bash_completion
index 98f4170..f5fcba9 100644
--- a/bash_completion
+++ b/bash_completion
@@ -2701,6 +2701,7 @@ shopt -u hostcomplete && complete -F _user_at_host $nospace talk ytalk finger
# Arguments: -a Use aliases
# -c Use `:' suffix
# -F configfile Use `configfile' for configuration settings
+# -h host Complete on given host
_known_hosts()
{
local configfile
@@ -2708,18 +2709,23 @@ _known_hosts()
local -a kh khd config
local IFS=$'\n'
- COMPREPLY=()
- cur=`_get_cword`
- ocur=$cur
-
local OPTIND=1
- while getopts "acF:" flag "$@"; do
+ local cur_set=0
+ while getopts "acF:h:" 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=()
--
bash-completion
More information about the Bash-completion-commits
mailing list