diff --git a/Makefile b/Makefile index 258f07e..bf2daa2 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ PREFIX ?= /usr BINDIR ?= $(PREFIX)/bin MANDIR ?= $(PREFIX)/share/man -CPLDIR ?= /etc/bash_completion.d +CPLDIR ?= $$(pkg-config --variable=completionsdir bash-completion) install: @echo Installing the executable to $(DESTDIR)$(BINDIR) @@ -13,8 +13,8 @@ install: @cp -f burrow.1 $(DESTDIR)$(MANDIR)/man1/burrow.1 @chmod 644 $(DESTDIR)$(MANDIR)/man1/burrow.1 @echo Installing the command completion to $(DESTDIR)$(CPLDIR) - @cp -f burrow.d $(DESTDIR)$(CPLDIR)/burrow.d - @chmod 644 $(DESTDIR)$(CPLDIR)/burrow.d + @cp -f burrow.d $(DESTDIR)$(CPLDIR)/burrow + @chmod 644 $(DESTDIR)$(CPLDIR)/burrow uninstall: @echo Removing the executable from $(DESTDIR)$(BINDIR) @@ -22,6 +22,6 @@ uninstall: @echo Removing the manual page from $(DESTDIR)$(MANDIR)/man1 @rm -f $(DESTDIR)$(BINDIR)/man1/burrow.1 @echo Removing the command completion from $(DESTDIR)$(CPLDIR) - @rm -f $(DESTDIR)$(CPLDIR)/burrow.d + @rm -f $(DESTDIR)$(CPLDIR)/burrow .PHONY: install uninstall diff --git a/burrow b/burrow index 01bd3b7..0fcd01e 100755 --- a/burrow +++ b/burrow @@ -75,6 +75,10 @@ function parseargs() { show_help exit 0 ;; + "SHORTLIST") + echo "phlog recipe create-config update-git" + exit 0 + ;; "PHLOG") arg_phlog=1 ;; "RECIPE") arg_recipe=1 ;; "CREATE-CONFIG") arg_create_config=1 ;; diff --git a/burrow.d b/burrow.d index 0993f73..cccce16 100644 --- a/burrow.d +++ b/burrow.d @@ -1,14 +1,14 @@ +#!/usr/bin/env bash + _burrow() { - local cur prev opts - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" - opts="phlog recipe create-config update-git -v -h" + # Get basic autocomplete commands from the function itself + local helplist + helplist=$(burrow shortlist) - if [[ ${cur} == -* ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 - fi + # Combine all the lists for autocomplete + local cur + cur=${COMP_WORDS[COMP_CWORD]} + COMPREPLY=( $( compgen -W "$helplist" -- "$cur" ) ) } complete -F _burrow burrow