mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 10:01:11 +02:00
20237: handle mysqlimport, more mysql options. Redo screen session completion
This commit is contained in:
parent
d8b1242723
commit
f4973986e9
3 changed files with 129 additions and 70 deletions
|
@ -1,5 +1,11 @@
|
||||||
2004-08-07 Oliver Kiddle <opk@zsh.org>
|
2004-08-07 Oliver Kiddle <opk@zsh.org>
|
||||||
|
|
||||||
|
* 20237: Completion/Unix/Command/_screen: rewrite completion of
|
||||||
|
screen sessions
|
||||||
|
|
||||||
|
* 20237: Completion/Unix/Command/_mysql_utils: complete for
|
||||||
|
mysqlimport and update some of the options
|
||||||
|
|
||||||
* 20236: Completion/Base/Completer/_expand: fix problem with
|
* 20236: Completion/Base/Completer/_expand: fix problem with
|
||||||
keep-prefix style where a modifier changes or removes the prefix
|
keep-prefix style where a modifier changes or removes the prefix
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,24 @@
|
||||||
#compdef mysql mysqlshow mysqldump mysqladmin
|
#compdef mysql mysqlshow mysqldump mysqlimport mysqladmin
|
||||||
|
|
||||||
# Adam Spiers <adam@spiers.net>
|
_mysql_get_identity() {
|
||||||
|
local _mysql_pass _mysql_sock
|
||||||
|
|
||||||
# Auxiliary functions
|
|
||||||
|
|
||||||
_mysql_get_identity () {
|
|
||||||
_mysql_user=${(v)opt_args[(i)-u|--user]}
|
_mysql_user=${(v)opt_args[(i)-u|--user]}
|
||||||
_mysql_port=${(v)opt_args[(i)-P|--port]}
|
_mysql_port=${(v)opt_args[(i)-P|--port]}
|
||||||
_mysql_host=${(v)opt_args[(i)-h|--host]}
|
_mysql_host=${(v)opt_args[(i)-h|--host]}
|
||||||
|
_mysql_pass=${(v)opt_args[(i)-p|--password]}
|
||||||
|
_mysql_sock=${(v)opt_args[(i)-S|--socket]}
|
||||||
|
|
||||||
_mysql_params=(
|
_mysql_params=(
|
||||||
${_mysql_user:+"--user=$_mysql_user"}
|
${_mysql_user:+"--user=$_mysql_user"}
|
||||||
${_mysql_host:+"--host=$_mysql_host"}
|
${_mysql_host:+"--host=$_mysql_host"}
|
||||||
${_mysql_port:+"--port=$_mysql_port"}
|
${_mysql_port:+"--port=$_mysql_port"}
|
||||||
|
${_mysql_pass:+"--password=$_mysql_pass"}
|
||||||
|
${_mysql_sock:+"--socket=$_mysql_sock"}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
_mysql_hosts () {
|
_mysql_hosts() {
|
||||||
local _mysql_user _mysql_port _mysql_host _mysql_params
|
local _mysql_user _mysql_port _mysql_host _mysql_params
|
||||||
_mysql_get_identity
|
_mysql_get_identity
|
||||||
|
|
||||||
|
@ -27,7 +29,7 @@ _mysql_hosts () {
|
||||||
hosts -
|
hosts -
|
||||||
}
|
}
|
||||||
|
|
||||||
_mysql_ports () {
|
_mysql_ports() {
|
||||||
local _mysql_user _mysql_port _mysql_host _mysql_params
|
local _mysql_user _mysql_port _mysql_host _mysql_params
|
||||||
_mysql_get_identity
|
_mysql_get_identity
|
||||||
|
|
||||||
|
@ -38,7 +40,7 @@ _mysql_ports () {
|
||||||
ports -
|
ports -
|
||||||
}
|
}
|
||||||
|
|
||||||
_mysql_users () {
|
_mysql_users() {
|
||||||
local _mysql_user _mysql_port _mysql_host _mysql_params
|
local _mysql_user _mysql_port _mysql_host _mysql_params
|
||||||
_mysql_get_identity
|
_mysql_get_identity
|
||||||
|
|
||||||
|
@ -49,7 +51,7 @@ _mysql_users () {
|
||||||
users -
|
users -
|
||||||
}
|
}
|
||||||
|
|
||||||
_mysql_databases () {
|
_mysql_databases() {
|
||||||
local _mysql_user _mysql_port _mysql_host _mysql_params
|
local _mysql_user _mysql_port _mysql_host _mysql_params
|
||||||
_mysql_get_identity
|
_mysql_get_identity
|
||||||
|
|
||||||
|
@ -57,7 +59,7 @@ _mysql_databases () {
|
||||||
mysql "$_mysql_params[@]" <<<'show databases' 2>/dev/null)"}[2,-1]}
|
mysql "$_mysql_params[@]" <<<'show databases' 2>/dev/null)"}[2,-1]}
|
||||||
}
|
}
|
||||||
|
|
||||||
_mysql_tables () {
|
_mysql_tables() {
|
||||||
local _mysql_user _mysql_port _mysql_host _mysql_params
|
local _mysql_user _mysql_port _mysql_host _mysql_params
|
||||||
_mysql_get_identity
|
_mysql_get_identity
|
||||||
|
|
||||||
|
@ -65,57 +67,57 @@ _mysql_tables () {
|
||||||
mysql "$_mysql_params[@]" $1 <<< 'show tables' 2>/dev/null)"}[2,-1]}
|
mysql "$_mysql_params[@]" $1 <<< 'show tables' 2>/dev/null)"}[2,-1]}
|
||||||
}
|
}
|
||||||
|
|
||||||
_mysql_variables () {
|
_mysql() {
|
||||||
_values -s , 'MySQL client variables' \
|
|
||||||
'max_allowed_packet[maximum allowed packet size]:packet size in bytes:' \
|
|
||||||
'net_buffer_length[network buffer length]:buffer length in bytes:'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# The actual completion code for the commands
|
|
||||||
|
|
||||||
_mysql () {
|
|
||||||
_arguments -s \
|
_arguments -s \
|
||||||
"$_mysql_common_opts[@]" \
|
"$_mysql_common_opts[@]" "$_mysql_variables_opts[@]" \
|
||||||
'(- :)'{-V,--version}'[display client version]' \
|
'(--disable-auto-rehash)--auto-rehash[enable automatic rehashing]' \
|
||||||
{-A,--no-auto-rehash}'[no automatic rehashing]' \
|
|
||||||
'(-t --table)'{-B,--batch}'[batch mode (no pretty ASCII)]' \
|
'(-t --table)'{-B,--batch}'[batch mode (no pretty ASCII)]' \
|
||||||
|
'--character-sets-dir=[specify directory containing character sets]:directory:_directories' \
|
||||||
|
'--default-character-set=[specify character set]:character set' \
|
||||||
{-T,--debug-info}'[print debug info on exit]' \
|
{-T,--debug-info}'[print debug info on exit]' \
|
||||||
{-e,--exec-command}':batch-execute specified command and exit: ' \
|
'(:)'{-D+,--database=}'[specify database to use]' \
|
||||||
|
{-e+,--exec=}':[execute specified command]:mysql command' \
|
||||||
{-f,--force}'[continue through errors]' \
|
{-f,--force}'[continue through errors]' \
|
||||||
{-i,--ignore-space}'[ignore space after function names]' \
|
'(--disable-named-commands)'{-G,--named-commands}'[enable named commands]' \
|
||||||
|
{-i,--ignore-spaces}'[ignore space after function names]' \
|
||||||
|
--local-infile \
|
||||||
|
{-b,--no-beep}'[turn off beep on error]' \
|
||||||
{-H,--html}'[produce HTML output]' \
|
{-H,--html}'[produce HTML output]' \
|
||||||
|
{-x,--xml}'[produce XML output]' \
|
||||||
|
'(--skip-line-numbers)--line-numbers[write line numbers for errors]' \
|
||||||
|
"(--line-numbers)--skip-line-numbers[don't write line numbers for errors]" \
|
||||||
{-n,--unbuffered}'[flush the buffer after each query]' \
|
{-n,--unbuffered}'[flush the buffer after each query]' \
|
||||||
{-O,--set-variable=}':set variable:_mysql_variables' \
|
'--column-names[write column names in results]' \
|
||||||
|
"--skip-column-names[don't write column names in results]" \
|
||||||
{-o,--one-database}'[only update the default database]' \
|
{-o,--one-database}'[only update the default database]' \
|
||||||
|
'--pager=[specify pager to use for displaying results]::pager' \
|
||||||
|
'--prompt=[set the mysql prompt to specified value]:prompt' \
|
||||||
{-q,--quick}'[disable caching of the result]' \
|
{-q,--quick}'[disable caching of the result]' \
|
||||||
{-r,--raw}'[write fields without conversion]' \
|
{-r,--raw}'[write fields without conversion]' \
|
||||||
{-s,--silent}'[silent mode]' \
|
{-s,--silent}'[silent mode]' \
|
||||||
{-L,--skip-line-numbers}"[don't write line number for errors]" \
|
|
||||||
{-N,--skip-column-names}"[don't write column names in results]" \
|
|
||||||
'(-B --batch)'{-t,--table}'[output in table format]' \
|
'(-B --batch)'{-t,--table}'[output in table format]' \
|
||||||
{-v,--verbose}'[verbose mode]' \
|
'(-B --batch)--tee=[append all output to file]:file:_files' \
|
||||||
|
{-U,--safe-updates}'[only allow UPDATE and DELETE that uses keys]' \
|
||||||
{-E,--vertical}'[print query output vertically]' \
|
{-E,--vertical}'[print query output vertically]' \
|
||||||
{-w,--wait}'[wait and retry server connection if necessary]' \
|
{-w,--wait}'[wait and retry server connection if necessary]' \
|
||||||
|
'(--pager)--disable-pager[print directly to stdout]' \
|
||||||
|
'(--auto-rehash)--disable-auto-rehash[disable automatic hashing]' \
|
||||||
|
'(-G --named-commands)--disable-named-commands' \
|
||||||
':MySQL database:_mysql_databases'
|
':MySQL database:_mysql_databases'
|
||||||
}
|
}
|
||||||
|
|
||||||
_mysqlshow () {
|
_mysqlshow() {
|
||||||
_arguments -s \
|
_arguments -s \
|
||||||
"$_mysql_common_opts[@]" \
|
"$_mysql_common_opts[@]" \
|
||||||
{-V,--version}'[display version]' \
|
|
||||||
{-\#+,--debug=}':debug file: ' \
|
|
||||||
':MySQL database to show:_mysql_databases' \
|
':MySQL database to show:_mysql_databases' \
|
||||||
':table to show:{ _mysql_tables "$line[1]" }' \
|
':table to show:{ _mysql_tables "$line[1]" }' \
|
||||||
':field wildcard: '
|
':field wildcard'
|
||||||
}
|
}
|
||||||
|
|
||||||
_mysqldump () {
|
_mysqldump() {
|
||||||
_arguments -s \
|
_arguments -s \
|
||||||
"$_mysql_common_opts[@]" \
|
"$_mysql_common_opts[@]" "$_mysql_variables_opts[@]" \
|
||||||
{-V,--version}'[display version]' \
|
|
||||||
{-a,--all}'[include all create options]' \
|
{-a,--all}'[include all create options]' \
|
||||||
{-\#+,--debug=}':debug file: ' \
|
|
||||||
{-c,--complete-insert}'[use complete insert statements]' \
|
{-c,--complete-insert}'[use complete insert statements]' \
|
||||||
{-e,--extended-insert}'[allow new INSERT syntax]' \
|
{-e,--extended-insert}'[allow new INSERT syntax]' \
|
||||||
"--add-drop-table[add a 'drop table' before each create]" \
|
"--add-drop-table[add a 'drop table' before each create]" \
|
||||||
|
@ -126,30 +128,46 @@ _mysqldump () {
|
||||||
{-l,--lock-tables}'[lock all tables for read]' \
|
{-l,--lock-tables}'[lock all tables for read]' \
|
||||||
{-t,--no-create-info}"[don't write table creation info]" \
|
{-t,--no-create-info}"[don't write table creation info]" \
|
||||||
{-d,--no-data}"[don't write row information]" \
|
{-d,--no-data}"[don't write row information]" \
|
||||||
{-O,--set-variable}':set variable:_mysql_variables' \
|
|
||||||
'--opt[create fastest possible dump for reading]' \
|
'--opt[create fastest possible dump for reading]' \
|
||||||
{-q,--quick}"[don't buffer, dump directly to stdout]" \
|
{-q,--quick}"[don't buffer, dump directly to stdout]" \
|
||||||
{-T,--tab=}"[dump tab-separated text files for each table]:directory to store text files:_files -/" \
|
{-T,--tab=}"[dump tab-separated text files for each table]:directory to store text files:_files -/" \
|
||||||
{-w+,--where=}'[dump only selected records]:WHERE clause to limit records to dump: ' \
|
{-w+,--where=}'[dump only selected records]:WHERE clause to limit records to dump: ' \
|
||||||
'--fields-terminated-by=:(with --tab) fields in textfile terminated by ...: ' \
|
'--fields-terminated-by=:(with --tab) fields in textfile terminated by ...:' \
|
||||||
'--fields-enclosed-by=:(with --tab) fields in import file enclosed by ...: ' \
|
'--fields-enclosed-by=:(with --tab) fields in import file enclosed by ...:' \
|
||||||
'--fields-optionally-enclosed-by=:(with --tab) fields in import file optionally enclosed by ...: ' \
|
'--fields-optionally-enclosed-by=:(with --tab) fields in import file optionally enclosed by ...:' \
|
||||||
'--fields-escaped-by=:(with --tab) fields in import file escaped by ...: ' \
|
'--fields-escaped-by=:(with --tab) fields in import file escaped by ...:' \
|
||||||
'--lines-terminated-by=:(with --tab) lines in import file terminated by ...: ' \
|
'--lines-terminated-by=:(with --tab) lines in import file terminated by ...:' \
|
||||||
':MySQL database to dump:_mysql_databases' \
|
':MySQL database to dump:_mysql_databases' \
|
||||||
'*:tables to dump:{ _mysql_tables "$line[1]" }'
|
'*:tables to dump:{ _mysql_tables "$line[1]" }'
|
||||||
}
|
}
|
||||||
|
|
||||||
_mysqladmin () {
|
_mysqlimport() {
|
||||||
|
_arguments -s \
|
||||||
|
"$_mysql_common_opts[@]" "$_mysql_variables_opts[@]" \
|
||||||
|
'(-c --columns)'{-c,--columns=}'[use only specified columns to import the data to]:column list' \
|
||||||
|
'(-d --delete)'{-d,--delete}'[first delete all rows from table]' \
|
||||||
|
'--fields-terminated-by=:fields in textfile terminated by ...:' \
|
||||||
|
'--fields-enclosed-by=:fields in import file enclosed by ...:' \
|
||||||
|
'--fields-optionally-enclosed-by=:fields in import file optionally enclosed by ...:' \
|
||||||
|
'--fields-escaped-by=:fields in import file escaped by ...:' \
|
||||||
|
'(-f --force)'{-f,--force}'[continue through errors]' \
|
||||||
|
'(-r --replace -i --ignore)'{-i,--ignore}'[if duplicate key found, keep old row]' \
|
||||||
|
'--ignore-lines=[ignore specified number of lines from input file]:number of lines' \
|
||||||
|
'--lines-terminated-by=[specify line terminator in input file]:terminator' \
|
||||||
|
'(-L --local)'{-L,--local}'[read all files through the client]' \
|
||||||
|
'(-l --lock-tables)'{-l,--lock-tables}'[lock all tables for write]' \
|
||||||
|
'--low-priority[use LOW_PRIORITY when updating the table]' \
|
||||||
|
'(-i --ignore -r --replace)'{-r,--replace}'[if duplicate key found, replace old row]' \
|
||||||
|
':MySQL database:_mysql_databases'
|
||||||
|
}
|
||||||
|
_mysqladmin() {
|
||||||
local curcontext="$curcontext" state line expl ret=1
|
local curcontext="$curcontext" state line expl ret=1
|
||||||
typeset -A opt_args
|
typeset -A opt_args
|
||||||
|
|
||||||
_arguments -C -s \
|
_arguments -C -s \
|
||||||
"$_mysql_common_opts[@]" \
|
"$_mysql_common_opts[@]" \
|
||||||
'(- *)'{-v,--version}'[display version]' \
|
|
||||||
'(-\# --debug)'{-\#+,--debug=}'[output debug log]:debug file' \
|
|
||||||
'(-f --force)'{-f,--force}'[continue through errors]' \
|
'(-f --force)'{-f,--force}'[continue through errors]' \
|
||||||
'(-i --sleep)'{-i+,--sleep=}'[repeat commands periodically]:number of seconds between executions: ' \
|
'(-i --sleep)'{-i+,--sleep=}'[repeat commands periodically]:number of seconds between executions' \
|
||||||
'(-s --silent)'{-s,--silent}"[silently exit if can't connect to server]" \
|
'(-s --silent)'{-s,--silent}"[silently exit if can't connect to server]" \
|
||||||
'(-t --timeout)'{-t+,--timeout=}'[specify timeout for connection]:time (seconds)' \
|
'(-t --timeout)'{-t+,--timeout=}'[specify timeout for connection]:time (seconds)' \
|
||||||
'(-w --wait)'{-w+,--wait=}'[wait and retry server connection if necessary]:number of retries' \
|
'(-w --wait)'{-w+,--wait=}'[wait and retry server connection if necessary]:number of retries' \
|
||||||
|
@ -159,14 +177,14 @@ _mysqladmin () {
|
||||||
if (( CURRENT == 1 )); then
|
if (( CURRENT == 1 )); then
|
||||||
_wanted commands expl 'mysqladmin command' compadd - \
|
_wanted commands expl 'mysqladmin command' compadd - \
|
||||||
create drop extended-status \
|
create drop extended-status \
|
||||||
flush-{hosts,logs,status,tables,privileges} \
|
flush-{hosts,logs,status,tables,threads,privileges} \
|
||||||
kill password ping processlist \
|
kill password ping processlist \
|
||||||
reload refresh shutdown \
|
reload refresh shutdown \
|
||||||
status variables version && ret=0
|
status start-slave stop-slave variables version && ret=0
|
||||||
else
|
else
|
||||||
case "${words[1]:t}" in
|
case "${words[1]:t}" in
|
||||||
create|drop)
|
create|drop)
|
||||||
_wanted databases expl "MySQL databases" _mysql_databases && ret=0
|
_wanted databases expl "MySQL database" _mysql_databases && ret=0
|
||||||
;;
|
;;
|
||||||
kill)
|
kill)
|
||||||
_message -e ids 'thread ids'
|
_message -e ids 'thread ids'
|
||||||
|
@ -181,17 +199,32 @@ _mysqladmin () {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
_mysql_utils () {
|
_mysql_utils() {
|
||||||
local _mysql_common_opts
|
local _mysql_common_opts _mysql_variables_opts
|
||||||
|
|
||||||
_mysql_common_opts=(
|
_mysql_common_opts=(
|
||||||
'(-)'{-\?,--help}'[display help]'
|
'(- *)'{-\?,--help}'[display help]'
|
||||||
|
'(- *)'{-V,--version}'[display version information]' \
|
||||||
|
{-\#+,--debug=}'[specify debug log file]:log file:_files'
|
||||||
|
'--print-defaults[print the program argument list and exit]'
|
||||||
|
"--no-defaults[don't read default options from any options file]"
|
||||||
|
'--defaults-file=[read defaults from the given file]:file:_files'
|
||||||
|
'--defaults-extra-file=[read specified file after the global files]:defaults file:_files'
|
||||||
'(-S --socket)'{-S+,--socket=}'[specify socket file to use for connection]:server socket file:_files'
|
'(-S --socket)'{-S+,--socket=}'[specify socket file to use for connection]:server socket file:_files'
|
||||||
'(-h --host)'{-h+,--host=}'[specify server hostname]:hostname:_mysql_hosts'
|
'(-h --host)'{-h+,--host=}'[specify server hostname]:hostname:_mysql_hosts'
|
||||||
'(-P,--port)'{-P+,--port=}'[specify port number for connection]:server port:_mysql_ports'
|
'(-P,--port)'{-P+,--port=}'[specify port number for connection]:server port:_mysql_ports'
|
||||||
'(-u --user)'{-u+,--user=}'[specify username for login]:server username:_mysql_users'
|
'(-u --user)'{-u+,--user=}'[specify username for login]:server username:_mysql_users'
|
||||||
'(-p --password)'{-p+,--password=}'[specify password to use for connection]:server password'
|
'(-p --password)'{-p-,--password=}'[specify password to use for connection]:server password'
|
||||||
'(-C --compress)'{-C,--compress}'[use compression in server/client protocol]'
|
'(-C --compress)'{-C,--compress}'[use compression in server/client protocol]'
|
||||||
|
\*{-v,--verbose}'[more verbose output]'
|
||||||
|
)
|
||||||
|
|
||||||
|
_mysql_variables_opts=(
|
||||||
|
'--max_allowed_packet[maximum allowed packet size]:packet size in bytes'
|
||||||
|
'--net_buffer_length[network buffer length]:buffer length in bytes'
|
||||||
|
'--connect_timeout:timeout'
|
||||||
|
'--select_limit:limit'
|
||||||
|
'--max_join_size:size'
|
||||||
)
|
)
|
||||||
|
|
||||||
case "$service" in
|
case "$service" in
|
||||||
|
@ -204,6 +237,9 @@ _mysql_utils () {
|
||||||
mysqldump)
|
mysqldump)
|
||||||
_mysqldump "$@"
|
_mysqldump "$@"
|
||||||
;;
|
;;
|
||||||
|
mysqlimport)
|
||||||
|
_mysqlimport "$@"
|
||||||
|
;;
|
||||||
mysqladmin)
|
mysqladmin)
|
||||||
_mysqladmin "$@"
|
_mysqladmin "$@"
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#compdef screen
|
#compdef screen
|
||||||
#Generated by Felix Rosencrantz
|
|
||||||
|
local curcontext="$curcontext" state line expl
|
||||||
|
local scr_cmds sessions
|
||||||
|
|
||||||
local context state line scr_cmds
|
|
||||||
typeset -A opt_args
|
|
||||||
scr_cmds=(
|
scr_cmds=(
|
||||||
acladd aclchg acldel aclgrp aclumask
|
acladd aclchg acldel aclgrp aclumask
|
||||||
activity addacl allpartial at attrcolor
|
activity addacl allpartial at attrcolor
|
||||||
|
@ -40,12 +40,12 @@ scr_cmds=(
|
||||||
xon zombie
|
xon zombie
|
||||||
)
|
)
|
||||||
|
|
||||||
_arguments \
|
_arguments -C \
|
||||||
"-a[force all capabilities into each window's termcap]" \
|
"-a[force all capabilities into each window's termcap]" \
|
||||||
'-A[adapt all windows to the new display width & height]' \
|
'-A[adapt all windows to the new display width & height]' \
|
||||||
"-c[read configuration file instead of '.screenrc']:config file:_files -/" \
|
"-c[read configuration file instead of '.screenrc']:config file:_files -/" \
|
||||||
'-d[detach the elsewhere running screen (with -r: reattach here)]:session name:->sessionname' \
|
'-d[detach the elsewhere running screen (with -r: reattach here)]: :->attached-sessions' \
|
||||||
'-dmS[start as daemon, screen session in detached mode]:session name:->sessionname' \
|
'-dmS[start as daemon, screen session in detached mode]: :->detached-sessions' \
|
||||||
'-D[detach and logout remote (with -r: reattach here)]' \
|
'-D[detach and logout remote (with -r: reattach here)]' \
|
||||||
'-e[change command characters]:command characters' \
|
'-e[change command characters]:command characters' \
|
||||||
'-f-[set flow control]:flow control:((n\:flow\ control\ off a\:flow\ control\ auto \:flow\ control\ on))' \
|
'-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]' \
|
'-O[choose optimal output rather than exact vt100 emulation]' \
|
||||||
'-p[preselect the named window]:window number or name:((\=\:windowlist -\:blank\ window \:window\ number))' \
|
'-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]' \
|
'-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]' \
|
'-R[reattach if possible, otherwise start a new session]' \
|
||||||
'-s[shell to execute rather than $SHELL]:shell name: _command_names -e' \
|
'-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' \
|
'-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[@]})' \
|
'-X[execute command as a screen command in the specified session]:screencmd:(${scr_cmds[@]})' \
|
||||||
'*::arguments: _normal'
|
'*::arguments: _normal'
|
||||||
|
|
||||||
case $state in
|
if [[ -n $state ]]; then
|
||||||
sessionname)
|
case $state in
|
||||||
# Complete session names
|
attached-sessions)
|
||||||
local screendir
|
sessions=(
|
||||||
screendir=( ${${${(M)${(f)"$(_call_program screen-sessions $words[1] -ls)"}:#*Socket*}%.}##* } )
|
${${${${(f)"$(_call_program screen-sessions $words[1] \
|
||||||
_wanted screen-sessions expl 'screen process' _path_files -W screendir
|
-ls)"}[2,-3]##[[:blank:]]}:#*Detached*}%[[:blank:]]*}
|
||||||
;;
|
)
|
||||||
esac
|
;;
|
||||||
|
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
|
||||||
|
|
Loading…
Reference in a new issue