From 79158704833a7550ac35cf3a56fa6207099dda83 Mon Sep 17 00:00:00 2001 From: "Emilly M.S." Date: Fri, 15 Mar 2024 22:06:09 -0300 Subject: [PATCH] Add bash completions for grimshot --- grimshot-bash-completion.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 grimshot-bash-completion.sh diff --git a/grimshot-bash-completion.sh b/grimshot-bash-completion.sh new file mode 100644 index 0000000..0ac8e54 --- /dev/null +++ b/grimshot-bash-completion.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +_grimshot_bash_comp() { + local req_target="copy save savecopy" + + # Complete options + if [[ ${COMP_WORDS[1]} =~ "-" && ${#COMP_WORDS[@]} -eq 2 ]]; then + COMPREPLY=( $(compgen -W "--notify --cursor --wait" -- "${COMP_WORDS[COMP_CWORD]}") ) + + # Complete commands + elif [[ ${#COMP_WORDS[@]} -eq 2 ]]; then + COMPREPLY=( $(compgen -W "check usage $req_target" -- "${COMP_WORDS[COMP_CWORD]}") ) + + # Complete targets + elif [[ $req_target =~ "${COMP_WORDS[1]}" && ${#COMP_WORDS[@]} -eq 3 ]]; then + COMPREPLY=( $(compgen -W "active screen output area window anything" -- "${COMP_WORDS[COMP_CWORD]}") ) + fi +} + +complete -F _grimshot_bash_comp grimshot