about summary refs log tree commit diff
path: root/Completion/Unix/Command/_screen
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2004-08-07 19:01:09 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2004-08-07 19:01:09 +0000
commitf4973986e9470328081d447ff5b20888b08eb8b6 (patch)
tree355a37a998a6f2a7ee1813320fbd6cf153ef1fbe /Completion/Unix/Command/_screen
parentd8b124272387ac306b75ac304d34543fab907326 (diff)
downloadzsh-f4973986e9470328081d447ff5b20888b08eb8b6.tar.gz
zsh-f4973986e9470328081d447ff5b20888b08eb8b6.tar.xz
zsh-f4973986e9470328081d447ff5b20888b08eb8b6.zip
20237: handle mysqlimport, more mysql options. Redo screen session completion
Diffstat (limited to 'Completion/Unix/Command/_screen')
-rw-r--r--Completion/Unix/Command/_screen49
1 files changed, 33 insertions, 16 deletions
diff --git a/Completion/Unix/Command/_screen b/Completion/Unix/Command/_screen
index 173e1a45b..a744fa72b 100644
--- a/Completion/Unix/Command/_screen
+++ b/Completion/Unix/Command/_screen
@@ -1,8 +1,8 @@
-#compdef screen 
-#Generated by Felix Rosencrantz
+#compdef screen
+
+local curcontext="$curcontext" state line expl
+local scr_cmds sessions
 
-local context state line scr_cmds
-typeset -A opt_args
 scr_cmds=(
   acladd	aclchg		acldel		aclgrp		aclumask
   activity	addacl		allpartial	at		attrcolor
@@ -40,12 +40,12 @@ scr_cmds=(
   xon		zombie
 )
 
-_arguments \
+_arguments -C \
   "-a[force all capabilities into each window's termcap]" \
   '-A[adapt all windows to the new display width & height]' \
   "-c[read configuration file instead of '.screenrc']:config file:_files -/" \
-  '-d[detach the elsewhere running screen (with -r: reattach here)]:session name:->sessionname' \
-  '-dmS[start as daemon, screen session in detached mode]:session name:->sessionname' \
+  '-d[detach the elsewhere running screen (with -r: reattach here)]: :->attached-sessions' \
+  '-dmS[start as daemon, screen session in detached mode]: :->detached-sessions' \
   '-D[detach and logout remote (with -r: reattach here)]' \
   '-e[change command characters]:command characters' \
   '-f-[set flow control]:flow control:((n\:flow\ control\ off a\:flow\ control\ auto \:flow\ control\ on))' \
@@ -59,7 +59,7 @@ _arguments \
   '-O[choose optimal output rather than exact vt100 emulation]' \
   '-p[preselect the named window]:window number or name:((\=\:windowlist -\:blank\ window \:window\ number))' \
   '-q[quiet startup, exit with non-zero return code if unsuccessful]' \
-  '-r[reattach to a detached screen process]:session name:->sessionname' \
+  '-r[reattach to a detached screen process]: :->detached-sessions' \
   '-R[reattach if possible, otherwise start a new session]' \
   '-s[shell to execute rather than $SHELL]:shell name: _command_names -e' \
   '-S[name this session <pid>.sockname instead of <pid>.<tty>.<host>]:session name' \
@@ -72,11 +72,28 @@ _arguments \
   '-X[execute command as a screen command in the specified session]:screencmd:(${scr_cmds[@]})' \
   '*::arguments: _normal'
 
-case $state in
-  sessionname)
-  # Complete session names
-  local screendir
-  screendir=( ${${${(M)${(f)"$(_call_program screen-sessions $words[1] -ls)"}:#*Socket*}%.}##* } )
-  _wanted screen-sessions expl 'screen process' _path_files -W screendir
-  ;;
-esac
+if [[ -n $state ]]; then
+  case $state in
+    attached-sessions)
+      sessions=(
+	${${${${(f)"$(_call_program screen-sessions $words[1] \
+            -ls)"}[2,-3]##[[:blank:]]}:#*Detached*}%[[:blank:]]*}
+      )
+    ;;
+    detached-sessions)
+      sessions=(
+	${${${${(f)"$(_call_program screen-sessions $words[1] \
+            -ls)"}[2,-3]##[[:blank:]]}:#*Attached*}%[[:blank:]]*}
+      )
+    ;;
+  esac
+  
+  # check if initial PID is necessary to make sessions unambiguous
+  if [[ ${#${(u)sessions#*.}} -lt $#sessions ]]; then
+    _wanted screen-sessions expl "${state%-*} screen process" \
+	compadd -a sessions
+  else
+    _wanted screen-sessions expl "${state%-*} screen process" \
+	compadd ${sessions#*.}
+  fi
+fi