From 9fb45502a8ae5768cbefe1dd752ecf4bbda09987 Mon Sep 17 00:00:00 2001 From: Abraham Toriz Date: Thu, 29 Jul 2021 11:02:22 -0500 Subject: [PATCH] add bash completion --- completions/bash/tiempo-autocomplete.bash | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 completions/bash/tiempo-autocomplete.bash diff --git a/completions/bash/tiempo-autocomplete.bash b/completions/bash/tiempo-autocomplete.bash new file mode 100644 index 0000000..eb9c137 --- /dev/null +++ b/completions/bash/tiempo-autocomplete.bash @@ -0,0 +1,16 @@ +#!/bin/bash +_tiempo () +{ + cur="${COMP_WORDS[COMP_CWORD]}" + cmd="${COMP_WORDS[1]}" + + if [[ ( $cmd = s* || $cmd = d* ) && "$COMP_CWORD" = 2 ]]; then + COMPREPLY=($(compgen -W "$(echo "select distinct sheet from entries where sheet not like '\_%';" | z b)" $cur)) + return + elif [[ "$COMP_CWORD" = 1 ]]; then + CMDS="archive backend configure display edit in kill list now out resume sheet week month" + COMPREPLY=($(compgen -W "$CMDS" $cur)) + fi +} + +complete -F _tiempo 'z'