forked from github/abduco
Add Zsh completion
This commit is contained in:
parent
c3ea8f5bde
commit
fcac3b17ed
6
Makefile
6
Makefile
|
|
@ -10,6 +10,8 @@ LDFLAGS_STD ?= -lc -lutil
|
|||
STRIP ?= strip
|
||||
INSTALL ?= install
|
||||
|
||||
ZSHPREFIX ?= /usr/local
|
||||
|
||||
SRC = abduco.c
|
||||
|
||||
all: abduco
|
||||
|
|
@ -44,11 +46,15 @@ install: abduco
|
|||
@mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
||||
@sed "s/VERSION/${VERSION}/g" < abduco.1 > ${DESTDIR}${MANPREFIX}/man1/abduco.1
|
||||
@chmod 644 ${DESTDIR}${MANPREFIX}/man1/abduco.1
|
||||
@echo installing zsh completion file to ${DESTDIR}${ZSHPREFIX}/share/zsh/site-functions
|
||||
@install -Dm644 abduco.zsh ${DESTDIR}${ZSHPREFIX}/share/zsh/site-functions/_abduco
|
||||
|
||||
uninstall:
|
||||
@echo removing executable file from ${DESTDIR}${PREFIX}/bin
|
||||
@rm -f ${DESTDIR}${PREFIX}/bin/abduco
|
||||
@echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
|
||||
@rm -f ${DESTDIR}${MANPREFIX}/man1/abduco.1
|
||||
@echo removing zsh completion file from ${DESTDIR}/usr/share/zsh/site-functions
|
||||
@rm -f ${DESTDIR}${ZSHPREFIX}/share/zsh/site-functions/_abduco
|
||||
|
||||
.PHONY: all clean dist install-strip install uninstall debug
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
#compdef abduco
|
||||
|
||||
typeset -A opt_args
|
||||
|
||||
_abduco_sessions() {
|
||||
declare -a sessions
|
||||
sessions=( $(abduco | sed '1d;s/.*\t[0-9][0-9]*\t//') )
|
||||
_describe -t session 'session' sessions
|
||||
}
|
||||
|
||||
_abduco_firstarg() {
|
||||
if (( $+opt_args[-a] || $+opt_args[-A] )); then
|
||||
_abduco_sessions
|
||||
elif (( $+opt_args[-c] || $+opt_args[-n] )); then
|
||||
_guard "^-*" 'session name'
|
||||
elif [[ -z $words[CURRENT] ]]; then
|
||||
compadd "$@" -S '' -- -
|
||||
fi
|
||||
}
|
||||
|
||||
_arguments -s \
|
||||
'(-a -A -c -n -f)-a[attach to an existing session]' \
|
||||
'(-a -A -c -n)-A[attach to a session, create if does not exist]' \
|
||||
'(-a -A -c -n -l)-c[create a new session and attach to it]' \
|
||||
'(-a -A -c -n -l)-n[create a new session but do not attach to it]' \
|
||||
'-e[set the detachkey (default: ^\\)]:detachkey' \
|
||||
'(-a)-f[force create the session]' \
|
||||
'(-q)-p[pass-through mode]' \
|
||||
'-q[be quiet]' \
|
||||
'-r[read-only session, ignore user input]' \
|
||||
'(-c -n)-l[attach with the lowest priority]' \
|
||||
'(-)-v[show version information and exit]' \
|
||||
'1: :_abduco_firstarg' \
|
||||
'2:command:_path_commands' \
|
||||
'*:: :{ shift $((CURRENT-3)) words; _precommand; }'
|
||||
Loading…
Reference in New Issue