1
0
mirror of https://git.envs.net/envs/burrow.git synced 2024-06-14 13:26:38 +00:00

added command completion

This commit is contained in:
James Tomasino 2018-01-20 15:02:34 -05:00
parent fbe12368b1
commit 5b835cab8c
3 changed files with 37 additions and 9 deletions

View File

@ -1,21 +1,27 @@
PREFIX ?= /usr
BINDIR ?= $(PREFIX)/bin
MANDIR ?= $(PREFIX)/share/man
CPLDIR ?= /etc/bash_completion.d
install:
@echo Installing the executable to $(DESTDIR)$(BINDIR)
@mkdir -p $(DESTDIR)$(BINDIR)
@cp -f burrow $(DESTDIR)$(BINDIR)/burrow
@chmod 755 $(DESTDIR)$(BINDIR)/burrow
@mkdir -p $(DESTDIR)$(BINDIR)
@cp -f burrow $(DESTDIR)$(BINDIR)/burrow
@chmod 755 $(DESTDIR)$(BINDIR)/burrow
@echo Installing the manual page to $(DESTDIR)$(MANDIR)/man1
@mkdir -p $(DESTDIR)$(MANDIR)
@mkdir -p $(DESTDIR)$(MANDIR)
@cp -f burrow.1 $(DESTDIR)$(MANDIR)/man1/burrow.1
@chmod 644 $(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
uninstall:
@echo Removing the executable from $(DESTDIR)$(BINDIR)
@rm -f $(DESTDIR)$(BINDIR)/burrow
@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
.PHONY: install uninstall

16
burrow
View File

@ -32,7 +32,7 @@ ARGUMENTS (multiple allowed):
phlog - create new phlog entry
recipe - add new recipe to box
create-config - create a default configuration file
update-git - pulls gopher git repo if exists
update-git - silently pulls gopher git repo if it exists
OPTIONAL FLAGS:
help [-h] - show this help
@ -41,6 +41,14 @@ verbose [-v] - verbose logging
END
}
pushd () {
command pushd "$@" 2>/dev/null 1>&2
}
popd () {
command popd 2>/dev/null 1>&2
}
function parseopts() {
while getopts ":hv" opt
do
@ -84,7 +92,7 @@ function day_suffix() {
esac
}
function update_gopher() {
function update_gopher_date() {
sed --in-place='' "s/.*Last\ Updated:.*/ ==== Last Updated: $(date +"%B %d$(day_suffix), %Y") ====/" "${config_location_gopher}/gophermap"
}
@ -129,7 +137,7 @@ function recipe_new() {
$editor "$post_path"
echo -e "0$title\t$(basename "$post_path")\n$(cat "${config_location_recipebox}/gophermap")" > "${config_location_recipebox}/gophermap"
sort -fo "${config_location_recipebox}/gophermap" "${config_location_recipebox}/gophermap"
update_gopher
update_gopher_date
if [[ $config_post_recipebox_command != "" ]]
then
@ -197,7 +205,7 @@ function phlog_new() {
rm "$links"
echo -e "1$(date +%Y-%m-%d) - $title\t$(basename "$post_dir")\n$(cat "${config_location_phlog}/gophermap")" > "${config_location_phlog}/gophermap"
update_gopher
update_gopher_date
if [[ $config_post_phlog_command != "" ]]
then

14
burrow.d Normal file
View File

@ -0,0 +1,14 @@
_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"
if [[ ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
}
complete -F _burrow burrow