From 0d82bda52640ede8960ae5b4bb5d00eb02e90108 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 25 Sep 2003 10:15:46 +0000 Subject: unposted: improve Perforce p4 -H completion --- Completion/Unix/Command/_perforce | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'Completion/Unix/Command/_perforce') diff --git a/Completion/Unix/Command/_perforce b/Completion/Unix/Command/_perforce index 8147244ba..8ec3baaaf 100644 --- a/Completion/Unix/Command/_perforce +++ b/Completion/Unix/Command/_perforce @@ -273,7 +273,7 @@ _perforce() { '-c+[client]:client:_perforce_clients' \ '-C+[charset]:charset:_perforce_charsets' \ '-d+[current directory]:directory:_path_files -g "*(/)"' \ - '-H+[hostname]:host:_hosts' \ + '-H+[hostname]:host:_perforce_hosts' \ '-G[python output]' \ '-L+[message language]:language: ' \ '-p+[server port]:port:_perforce_hosts_ports' \ @@ -1008,6 +1008,23 @@ _perforce_groups() { } +(( $+functions[_perforce_hosts] )) || +_perforce_hosts() { + local expl host + # Completion for p4 -H; other forms of host completion + # go through _perforce_hosts_ports. + # From Felix: if the client specifies a hostname, there's + # no point using any other host, since it won't work. + host=$(_perforce_call_p4 client client -o | + awk '$1 ~ /^Host:/ {print $2}' ) + if [[ -n $host ]]; then + _wanted hosts expl host compadd "$@" $host + else + _hosts + fi +} + + (( $+functions[_perforce_hosts_ports] )) || _perforce_hosts_ports() { if compset -P '*:'; then -- cgit 1.4.1