Skip to content

Instantly share code, notes, and snippets.

@kirtfitzpatrick
Last active June 13, 2024 15:22
Show Gist options
  • Save kirtfitzpatrick/e7a7828e99bae609955f08b35fc2c8b1 to your computer and use it in GitHub Desktop.
Save kirtfitzpatrick/e7a7828e99bae609955f08b35fc2c8b1 to your computer and use it in GitHub Desktop.
function _cdk_completer {
STACK_CMDS="list synthesize bootstrap deploy destroy diff metadata init context docs doctor"
if [ "$3" == "cdk" ]; then
COMPREPLY=($(compgen -W "$STACK_CMDS" $2))
elif [[ -d "cdk.out" ]] && ! [[ "$2" == "-"* ]]; then
TEMPLATES=$(ls -1 cdk.out/*.template.json | awk '{split($0,t,/\/|\./); print t[3]}')
COMPREPLY=($(compgen -W "$TEMPLATES" $2))
else
COMPREPLY=()
fi
}
complete -F _cdk_completer cdk
@mnoumanshahzad
Copy link

Thank you for sharing this snippet. Definitely comes in handy 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment