about summary refs log tree commit diff
path: root/Completion/Unix/Command/_screen
blob: a744fa72be680c396eb8d7a1c06f04d0311fc914 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#compdef screen

local curcontext="$curcontext" state line expl
local scr_cmds sessions

scr_cmds=(
  acladd	aclchg		acldel		aclgrp		aclumask
  activity	addacl		allpartial	at		attrcolor
  autodetach	autonuke	backtick	bce		bell_msg
  bind		bindkey		break		breaktype	bufferfile
  c1		caption		charset		chdir		clear
  colon		command		compacthist	console		copy
  copy_reg	crlf		debug		defautonuke	defbce
  defbreaktype	defc1		defcharset	defencoding	defescape
  defflow	defgr		defhstatus	defkanji	deflog
  deflogin	defmode		defmonitor	defobuflimit	defscrollback
  defshell	defsilence	defslowpaste	defutf8		defwrap
  defwritelock	defzombie	detach		digraph		dinfo
  displays	dumptermcap	echo		encoding	escape
  eval		exec		fit		flow		focus
  gr		hardcopy	hardcopy_append	hardcopydir	hardstatus
  height	help		history		hstatus		ignorecase
  info		ins_reg		kill		lastmsg		license
  lockscreen	log		logfile		login		logtstamp
  mapdefault	mapnotnext	maptimeout	markkeys	maxwin
  meta		monitor		msgminwait	msgwait		multiuser
  nethack	next		nonblock	number		obuflimit
  only		other		partial		password	paste
  pastefont	pow_break	pow_detach	pow_detach_msg	prev
  printcmd	process		quit		readbuf		readreg
  redisplay	register	remove		removebuf	reset
  resize	screen		scrollback	select		sessionname
  setenv	setsid		shell		shelltitle	silence
  silencewait	sleep		slowpaste	sorendition	source
  split		startup_message	stuff		su		term
  termcap	termcapinfo	terminfo	time		title
  unsetenv	utf8		vbell		vbell_msg	vbellwait
  verbose	version		wall		width		windowlist
  windows	wrap		writebuf	writelock	xoff
  xon		zombie
)

_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)]: :->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))' \
  '-h[set the size of the scrollback history buffer]:buffer size' \
  '-i[interrupt output sooner when flow control is on]' \
  '(-l)-ln[login mode off (do not update utmp database)]' \
  '(-ln)-l[login mode on (update utmp database)]' \
  '(-)'{-ls,-list}'[list sessions/socket directory]' \
  "-L[terminal's last character can be safely updated]" \
  '-m[ignore $STY variable, do create a new screen session]' \
  '-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]: :->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' \
  "-t[set title (window's name)]:title" \
  '-T[use term as $TERM for windows, rather than "screen"]:terminal type:_terminals' \
  '-U[tell screen to use UTF-8 encoding]' \
  '(-)-v[print screen version]' \
  '(-)-wipe[do nothing, clean up SockDir]' \
  '-x[attach to a not detached screen (multi display mode)]' \
  '-X[execute command as a screen command in the specified session]:screencmd:(${scr_cmds[@]})' \
  '*::arguments: _normal'

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