Skip to content

Commit 3393a04

Browse files
committed
Add AWS CLI autocomplete support for bash, zsh, and fish shells
1 parent 75fd523 commit 3393a04

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

registry/ausbru87/modules/aws-cli/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tags: [helper, aws, cli]
88

99
# AWS CLI
1010

11-
Automatically install the [AWS CLI v2](https://aws.amazon.com/cli/) in your Coder workspace.
11+
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.
1212

1313
```tf
1414
module "aws-cli" {
@@ -19,6 +19,13 @@ module "aws-cli" {
1919
}
2020
```
2121

22+
## Features
23+
24+
- Installs AWS CLI v2 for Linux and macOS
25+
- Supports x86_64 and ARM64 architectures
26+
- Optional version pinning
27+
- **Auto-configures command autocomplete** for bash, zsh, and fish shells
28+
2229
## Examples
2330

2431
### Basic Installation

registry/ausbru87/modules/aws-cli/run.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,42 @@ else
6666
printf "❌ AWS CLI installation failed. Check logs at ${LOG_PATH}\n"
6767
exit 1
6868
fi
69+
70+
# Configure autocomplete for common shells
71+
if command -v aws_completer > /dev/null 2>&1; then
72+
AWS_COMPLETER_PATH=$(which aws_completer)
73+
74+
# Bash autocomplete
75+
if [ -f ~/.bashrc ]; then
76+
if ! grep -q "aws_completer.*aws" ~/.bashrc; then
77+
echo "complete -C '$AWS_COMPLETER_PATH' aws" >> ~/.bashrc
78+
printf "✓ Configured AWS CLI autocomplete for bash\n"
79+
fi
80+
fi
81+
82+
# Zsh autocomplete
83+
if [ -f ~/.zshrc ] || [ -d ~/.oh-my-zsh ]; then
84+
if ! grep -q "aws_completer.*aws" ~/.zshrc 2> /dev/null; then
85+
cat >> ~/.zshrc << EOF
86+
87+
# AWS CLI autocomplete
88+
autoload bashcompinit && bashcompinit
89+
autoload -Uz compinit && compinit
90+
complete -C '$AWS_COMPLETER_PATH' aws
91+
EOF
92+
printf "✓ Configured AWS CLI autocomplete for zsh\n"
93+
fi
94+
fi
95+
96+
# Fish autocomplete
97+
if [ -d ~/.config/fish ] || command -v fish > /dev/null 2>&1; then
98+
mkdir -p ~/.config/fish/completions
99+
FISH_COMPLETION=~/.config/fish/completions/aws.fish
100+
if [ ! -f "$FISH_COMPLETION" ]; then
101+
cat > "$FISH_COMPLETION" << 'EOF'
102+
complete --command aws --no-files --arguments '(begin; set --local --export COMP_SHELL fish; set --local --export COMP_LINE (commandline); aws_completer | sed '"'"'s/ $//'"'"'; end)'
103+
EOF
104+
printf "✓ Configured AWS CLI autocomplete for fish\n"
105+
fi
106+
fi
107+
fi

0 commit comments

Comments
 (0)