From ba6921c91d1ec80eff623f833e3d245683401002 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Tue, 3 May 2016 13:05:44 -0400 Subject: [PATCH] CLI: command completions in bash, bash-like shells --- bash/command-completion | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 bash/command-completion diff --git a/bash/command-completion b/bash/command-completion new file mode 100644 index 000000000..7ad26ee4f --- /dev/null +++ b/bash/command-completion @@ -0,0 +1,24 @@ +_gramps() +{ + local cur prev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts="--action --config --create --databases --debug --export --format --help --import --open --options --quiet --remove --show --usage --version --yes -? -C -L -O -a -b -c -d -e -f -i -l -p -q -r -s -t -u -v -y" + if [[ ${cur} == -* ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + elif [[ ${cur} == --open ]] ; then + local IFS=$'\n' + local names=($( ./Gramps.py -l | grep \" | cut -d\ -f4- )) + COMPREPLY=( $(compgen --W "${names[*]}" -- ${cur}) ) + return 0 + else + local IFS=$'\n' + local names=($( ./Gramps.py -l | grep \" | cut -d\ -f4- )) + COMPREPLY=( $(compgen -W "${names[*]}" -- ${cur}) ) + return 0 + fi +} +complete -F _gramps gramps +complete -F _gramps ./Gramps.py