add bash completion support
This commit is contained in:
12
Makefile
12
Makefile
@ -2,12 +2,20 @@ NAME=pulseaudio-tcp
|
|||||||
PREFIX=/usr
|
PREFIX=/usr
|
||||||
BINDIR=$(PREFIX)/bin
|
BINDIR=$(PREFIX)/bin
|
||||||
APPDIR=$(PREFIX)/share/applications
|
APPDIR=$(PREFIX)/share/applications
|
||||||
|
COMPLETIONDIR=$(PREFIX)/share/bash-completion/completions
|
||||||
DESTDIR=
|
DESTDIR=
|
||||||
|
|
||||||
.PHONY: all install-bin install-desktop install
|
.PHONY: all install-bash install-bin install-desktop install
|
||||||
|
|
||||||
all:
|
all:
|
||||||
|
|
||||||
|
install-bash: $(NAME).bash_completion
|
||||||
|
@install -d -m 755 "$(DESTDIR)$(COMPLETIONDIR)"
|
||||||
|
@install -m 644 \
|
||||||
|
"$(NAME).bash_completion" \
|
||||||
|
"$(DESTDIR)$(COMPLETIONDIR)/$(NAME)"
|
||||||
|
@echo "INFO: Bourne Again Shell completion for $(NAME) was installed to $(COMPLETIONDIR)"
|
||||||
|
|
||||||
install-bin: $(NAME)
|
install-bin: $(NAME)
|
||||||
@install -d -m 755 "$(DESTDIR)$(BINDIR)"
|
@install -d -m 755 "$(DESTDIR)$(BINDIR)"
|
||||||
@install -m 755 "$(NAME)" "$(DESTDIR)$(BINDIR)"/"$(NAME)"
|
@install -m 755 "$(NAME)" "$(DESTDIR)$(BINDIR)"/"$(NAME)"
|
||||||
@ -24,7 +32,7 @@ install-desktop: $(NAME).desktop.in
|
|||||||
> "$(DESTDIR)$(APPDIR)"/"$(NAME)".desktop
|
> "$(DESTDIR)$(APPDIR)"/"$(NAME)".desktop
|
||||||
@echo "INFO: $(NAME).desktop was installed to $(APPDIR)"
|
@echo "INFO: $(NAME).desktop was installed to $(APPDIR)"
|
||||||
|
|
||||||
install: install-bin install-desktop
|
install: install-bash install-bin install-desktop
|
||||||
@if test -z "$(DESTDIR)" ; then \
|
@if test -z "$(DESTDIR)" ; then \
|
||||||
if test -n "$$(which update-desktop-database)" ; then \
|
if test -n "$$(which update-desktop-database)" ; then \
|
||||||
update-desktop-database "$(APPDIR)" ; \
|
update-desktop-database "$(APPDIR)" ; \
|
||||||
|
22
pulseaudio-tcp.bash_completion
Normal file
22
pulseaudio-tcp.bash_completion
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
_pulseaudio_tcp_completions() {
|
||||||
|
local cur options commands delete
|
||||||
|
|
||||||
|
cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
|
options=( "--debug" "--help" "--nogui" )
|
||||||
|
commands=( "start" "stop" "status" "setup" "restart" )
|
||||||
|
|
||||||
|
for delete in "${COMP_WORDS[@]::${#COMP_WORDS[@]}-1}" ; do
|
||||||
|
options=("${options[@]/$delete}")
|
||||||
|
commands=("${commands[@]/$delete}")
|
||||||
|
done
|
||||||
|
|
||||||
|
COMPREPLY=()
|
||||||
|
|
||||||
|
case "$cur" in
|
||||||
|
'') mapfile -t COMPREPLY < <(compgen -W "${options[*]} ${commands[*]}" -- "$cur") ;;
|
||||||
|
-*) mapfile -t COMPREPLY < <(compgen -W "${options[*]}" -- "$cur") ;;
|
||||||
|
[^-]*) mapfile -t COMPREPLY < <(compgen -W "${commands[*]}" -- "$cur") ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return 0
|
||||||
|
} && complete -F _pulseaudio_tcp_completions pulseaudio-tcp
|
Reference in New Issue
Block a user