summary refs log tree commit diff
path: root/Completion/Unix/Command/_mosh
diff options
context:
space:
mode:
authorOliver Kiddle <okiddle@yahoo.co.uk>2018-03-24 00:09:12 +0100
committerOliver Kiddle <okiddle@yahoo.co.uk>2018-03-24 00:09:12 +0100
commit4977ec13982bc851668e85924e30a57c4e304b6e (patch)
treea8ecb5be3d0c51a366107d5c941a87e02fbd0e3e /Completion/Unix/Command/_mosh
parentf1a52c23fa6c3c27c32b6a04d731b7d2c2f3c4b4 (diff)
downloadzsh-4977ec13982bc851668e85924e30a57c4e304b6e.tar.gz
zsh-4977ec13982bc851668e85924e30a57c4e304b6e.tar.xz
zsh-4977ec13982bc851668e85924e30a57c4e304b6e.zip
42491 based on 42000 (Andrei Shevchuk): factor ssh host completion for use for mosh and git
Diffstat (limited to 'Completion/Unix/Command/_mosh')
-rw-r--r--Completion/Unix/Command/_mosh16
1 files changed, 12 insertions, 4 deletions
diff --git a/Completion/Unix/Command/_mosh b/Completion/Unix/Command/_mosh
index 431fdbf9e..aa97587bb 100644
--- a/Completion/Unix/Command/_mosh
+++ b/Completion/Unix/Command/_mosh
@@ -1,6 +1,6 @@
 #compdef mosh
 
-local curcontext="$curcontext" state line
+local curcontext="$curcontext" state line expl ret=1
 local -a _comp_priv_prefix
 
 _arguments -C \
@@ -15,12 +15,20 @@ _arguments -C \
   '--server[specify command to run server helper]:remote file:_files' \
   '--client[specify command to run client helper]:_command_names -e' \
   '1:remote host name:->userhost' \
-  '*:::args:_normal' && return
+  '*:::args:_normal' && ret=0
 
 case $state in
   userhost)
-    _hosts || _user_at_host && return
+    if compset -P '*@'; then
+      _wanted hosts expl 'remote host name' _ssh_hosts && ret=0
+    elif compset -S '@*'; then
+      _wanted users expl 'login name' _combination -s '[:@]' my-accounts users-hosts users -S '' && ret=0
+    else
+      _alternative \
+	'hosts:remote host name:_ssh_hosts' \
+	'users:login name:_combination -s "[:@]" my-accounts users-hosts users -qS@' && ret=0
+    fi
   ;;
 esac
 
-return 1
+return ret