-
Notifications
You must be signed in to change notification settings - Fork 714
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from sorin-ionescu/attach
Add attach completion.
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#compdef attach | ||
# ------------------------------------------------------------------------------ | ||
# Description | ||
# ----------- | ||
# | ||
# Completion script for attach (http://github.com/sorin-ionescu/attach). | ||
# | ||
# ------------------------------------------------------------------------------ | ||
# Authors | ||
# ------- | ||
# | ||
# * Sorin Ionescu <sorin.ionescu@gmail.com> | ||
# | ||
# ------------------------------------------------------------------------------ | ||
|
||
local state mode_values existing_sessions ret=1 | ||
|
||
mode_values=( | ||
"none:Disable redrawing completely" | ||
"ctrl_l:Send a ^L character if the terminal is in char-at-a-time mode to the program" | ||
"winch:Send a WINCH signal to the program" | ||
) | ||
|
||
existing_sessions=($(_call_program session attach)) | ||
|
||
_arguments -C -s -S \ | ||
'(--list -l)'{--list,-l}'[List sessions]' \ | ||
'(--sockets -L)'{--sockets,-L}'[List sockets]' \ | ||
'(--session -s)'{--session=,-s+}'[Set the session name]:session' \ | ||
'(--char -c)'{--char=,-c+}'[Set the detach character (default: ^\\)]:char' \ | ||
'(--redraw -r)'{--redraw=,-r+}'[Set the redraw method (none, ctrl_l, or winch)]:mode:->mode' \ | ||
'(--detached -d)'{--detached,-d}'[Start the session detched]' \ | ||
'(--no-detach -D)'{--no-detach,-D}'[Disable detaching]' \ | ||
'(--no-suspend -Z)'{--no-suspend,-Z}'[Disable suspending]' \ | ||
'(--version -v)'{--version,-v}'[Display version and copyright]' \ | ||
'(--help -h)'{--help,-h}'[Display this help]' \ | ||
'(-)::args:->session-or-command' && ret=0 | ||
|
||
case "$state" in | ||
(mode) | ||
_describe -t mode 'redraw mode' mode_values && ret=0 | ||
;; | ||
(session-or-command) | ||
_describe -t 'session' 'sessions' existing_sessions && ret=0 | ||
_path_commands && ret=0 | ||
;; | ||
esac | ||
|
||
return $ret | ||
|