From f4973986e9470328081d447ff5b20888b08eb8b6 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Sat, 7 Aug 2004 19:01:09 +0000 Subject: 20237: handle mysqlimport, more mysql options. Redo screen session completion --- Completion/Unix/Command/_screen | 49 +++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 16 deletions(-) (limited to 'Completion/Unix/Command/_screen') 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 .sockname instead of ..]: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 -- cgit 1.4.1