From 62d937425222276a10093c5a54030e5a45d41197 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 28 Jan 2018 00:42:30 +0100 Subject: 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. --- harvester.bash-completion | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 harvester.bash-completion 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 -- cgit v1.2.3