aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-01-28 00:42:30 +0100
committerTeddy Wing2018-01-28 00:42:30 +0100
commit62d937425222276a10093c5a54030e5a45d41197 (patch)
tree2c6170919ee251aba890abb080bc24547c534a07
parent484f616ce69edd17f03f762d441b47ae20027c6c (diff)
downloadharvester-62d937425222276a10093c5a54030e5a45d41197.tar.bz2
Add harvester.bash-completion
A Bash completion function to complete project file names. Doesn't work with the `--project=` form as I couldn't figure out how to get it to do that in an easy way so finally decided not to bother because I don't use that form anyway.
-rw-r--r--harvester.bash-completion20
1 files changed, 20 insertions, 0 deletions
diff --git a/harvester.bash-completion b/harvester.bash-completion
new file mode 100644
index 0000000..b785a63
--- /dev/null
+++ b/harvester.bash-completion
@@ -0,0 +1,20 @@
+function _harvester () {
+ local cur
+ local previous
+ local hcl_aliases_file=~/.hcl/aliases
+ local projects=$(sed 's/@//g' "$hcl_aliases_file")
+
+ COMPREPLY=()
+ cur=${COMP_WORDS[COMP_CWORD]}
+ previous=${COMP_WORDS[COMP_CWORD - 1]}
+
+ if [ "$previous" = '-p' \
+ -o "$previous" = '--project' \
+ ]; then
+ COMPREPLY=( $(compgen -W "$projects" -- $cur) )
+ fi
+
+ return 0
+}
+
+complete -F _harvester harvester