From 67b2d2dadfb6194fdc00fd28c19e99fbcb47abfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Drago=C8=99=20Str=C4=83inu?= Date: Mon, 7 Mar 2022 14:23:53 +0200 Subject: [PATCH] feat: add autocomplete --- tt.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tt.sh b/tt.sh index 120ecac..592c407 100755 --- a/tt.sh +++ b/tt.sh @@ -180,3 +180,20 @@ tt() { _options "$1" "$2" fi } + +# Autocomplete +# taken https://askubuntu.com/questions/68175/how-to-create-script-with-auto-complete +_tt() +{ + local cur prev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts="--help --start --pause --done --finish --abort --clear-logs --activity-name --logs" + + if [[ ${cur} == -* ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + fi +} +complete -F _tt tt