about summary refs log tree commit diff
path: root/Completion/Unix
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2003-09-25 10:15:46 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2003-09-25 10:15:46 +0000
commit0d82bda52640ede8960ae5b4bb5d00eb02e90108 (patch)
tree4db6679c7db33a2d5a37a8145b4373191a628a2d /Completion/Unix
parenta869fe1c57acd59f0908a2968034bdd0e1ec7664 (diff)
downloadzsh-0d82bda52640ede8960ae5b4bb5d00eb02e90108.tar.gz
zsh-0d82bda52640ede8960ae5b4bb5d00eb02e90108.tar.xz
zsh-0d82bda52640ede8960ae5b4bb5d00eb02e90108.zip
unposted: improve Perforce p4 -H completion
Diffstat (limited to 'Completion/Unix')
-rw-r--r--Completion/Unix/Command/_perforce19
1 files changed, 18 insertions, 1 deletions
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