From 3393a04272850fbb198b53008722f2d1e7eba376 Mon Sep 17 00:00:00 2001 From: Austen Bruhn Date: Sat, 15 Nov 2025 17:50:21 -0700 Subject: [PATCH] Add AWS CLI autocomplete support for bash, zsh, and fish shells --- registry/ausbru87/modules/aws-cli/README.md | 9 ++++- registry/ausbru87/modules/aws-cli/run.sh | 39 +++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/registry/ausbru87/modules/aws-cli/README.md b/registry/ausbru87/modules/aws-cli/README.md index 0c0b0d16..0ded3d20 100644 --- a/registry/ausbru87/modules/aws-cli/README.md +++ b/registry/ausbru87/modules/aws-cli/README.md @@ -8,7 +8,7 @@ tags: [helper, aws, cli] # AWS CLI -Automatically install the [AWS CLI v2](https://aws.amazon.com/cli/) in your Coder workspace. +Automatically install the [AWS CLI v2](https://aws.amazon.com/cli/) in your Coder workspace with command autocomplete support for bash, zsh, and fish shells. ```tf module "aws-cli" { @@ -19,6 +19,13 @@ module "aws-cli" { } ``` +## Features + +- Installs AWS CLI v2 for Linux and macOS +- Supports x86_64 and ARM64 architectures +- Optional version pinning +- **Auto-configures command autocomplete** for bash, zsh, and fish shells + ## Examples ### Basic Installation diff --git a/registry/ausbru87/modules/aws-cli/run.sh b/registry/ausbru87/modules/aws-cli/run.sh index b78c97dd..b2b25ccd 100755 --- a/registry/ausbru87/modules/aws-cli/run.sh +++ b/registry/ausbru87/modules/aws-cli/run.sh @@ -66,3 +66,42 @@ else printf "❌ AWS CLI installation failed. Check logs at ${LOG_PATH}\n" exit 1 fi + +# Configure autocomplete for common shells +if command -v aws_completer > /dev/null 2>&1; then + AWS_COMPLETER_PATH=$(which aws_completer) + + # Bash autocomplete + if [ -f ~/.bashrc ]; then + if ! grep -q "aws_completer.*aws" ~/.bashrc; then + echo "complete -C '$AWS_COMPLETER_PATH' aws" >> ~/.bashrc + printf "✓ Configured AWS CLI autocomplete for bash\n" + fi + fi + + # Zsh autocomplete + if [ -f ~/.zshrc ] || [ -d ~/.oh-my-zsh ]; then + if ! grep -q "aws_completer.*aws" ~/.zshrc 2> /dev/null; then + cat >> ~/.zshrc << EOF + +# AWS CLI autocomplete +autoload bashcompinit && bashcompinit +autoload -Uz compinit && compinit +complete -C '$AWS_COMPLETER_PATH' aws +EOF + printf "✓ Configured AWS CLI autocomplete for zsh\n" + fi + fi + + # Fish autocomplete + if [ -d ~/.config/fish ] || command -v fish > /dev/null 2>&1; then + mkdir -p ~/.config/fish/completions + FISH_COMPLETION=~/.config/fish/completions/aws.fish + if [ ! -f "$FISH_COMPLETION" ]; then + cat > "$FISH_COMPLETION" << 'EOF' +complete --command aws --no-files --arguments '(begin; set --local --export COMP_SHELL fish; set --local --export COMP_LINE (commandline); aws_completer | sed '"'"'s/ $//'"'"'; end)' +EOF + printf "✓ Configured AWS CLI autocomplete for fish\n" + fi + fi +fi