msmtp-notify \
repo-encrypt \
+bash-completion = \
+repo-encrypt \
+
dir := $(abspath $(wildcard $(INSTALL)))
+dir-completion := $(dir)/bash_completion.d
default: help
-install: $(foreach s, $(scripts), $(dir)/$(s))
+install: $(dir) $(dir-completion) \
+$(foreach f, $(scripts), $(dir)/$(f)) \
+$(foreach f, $(bash-completion), $(dir-completion)/$(f)) \
$(dir)/%: %
cp -f $< $@
chmod +x $@
+$(dir-completion)/%: bash_completion.d/%
+ cp -f $< $@
+$(dir) $(dir-completion):
+ mkdir -p $@
help:
@echo "Run make install or see README."
Please send patches, bug reports and comments to Gustav Eek
<gustav@fripost.org>
-# Licence
-Copyright 2014 Gustav Eek.
+License
+=======
+
+Copyright (c) 2014--2015 Gustav Eek <gustav@fripost.org>.
The script set in this repository is free software: you can
redistribute it and/or modify it under the terms of the GNU General
along with this script set. If not, see
<http://www.gnu.org/licenses/>.
-# Configuration
-
-Configural parameters are installation directory. Open Makefile
-# Compilation
+Configuration
+=============
-No compilation is needed.
+Configurable parameters are installation directory. Edit `Makefile`
+directly.
-# Installation
+Installation
+============
For installation type
- $ make install
+ $ make install
+
+For Bash autocompletion on some of the commands, put the following
+lines in your `~/.bash_completion` or `~/.bashrc`
+
+ DIR="$HOME/bin/bash_completion.d"
+ if [[ -d "$DIR" ]]; then
+ for f in $(ls "$DIR"); do
+ if [[ -f "$DIR/$f" ]]; then
+ source "$DIR/$f"
+ fi
+ done
+ fi
+ unset DIR
-# Help
+Help
+====
Some scripts include help command, in that case type
- $ <script> --help
+ $ <script> --help
--- /dev/null
+#!/bin/bash
+#
+# This file provides programmable completion for repo-encrypt under
+# the bash shell
+
+function _repo-encrypt {
+
+ local cmd cur prev line subcmds opts
+ COMPREPLY=()
+ cmd="${1##*/}"
+ cur="${COMP_WORDS[COMP_CWORD]}" # called 'cur' by convention [1]
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ line="${COMP_LINE}"
+ subcmds="encrypt decrypt"
+ opts="--help"
+
+ if [[ "$COMP_CWORD" == 1 ]]; then
+ COMPREPLY=($(compgen -W "${subcmds} ${opts}" -- "${cur}"))
+ return 0
+ elif [[ ${COMP_WORDS[1]} == "--help" ]]; then
+ COMPREPLY=(" ") # none empty
+ >&2 printf "\n${cmd}: No completion on '--help'"
+ return 0
+ fi
+
+ return 0
+}
+
+complete -o filenames -o default -F _repo-encrypt repo-encrypt # There are details [2]
+
+# [1]: http://tldp.org/LDP/abs/html/tabexpansion.html
+# [2]: http://www.gnu.org/software/bash/manual/bash.html#Programmable-Completion