From fdea3476593b7438c1bff575483fe5cb1cf1b348 Mon Sep 17 00:00:00 2001 From: Daeghan Elkin Date: Tue, 21 Apr 2026 01:44:45 +0000 Subject: [PATCH] fix(aws-cli): fix ZSH completion installation The ZSH completer script provided by the aws/aws-cli repo is not set up to be used as a completer function, and thus cannot be dropped into a directory like ~/.oh-my-zsh/completions and be expected to work. This change also moves the completer to a more standard location for system-wide ZSH completions, and adds the necessary header to make it work as a completer. --- src/aws-cli/devcontainer-feature.json | 2 +- src/aws-cli/install.sh | 12 +++++------- test/aws-cli/scenarios.json | 9 +++++++++ test/aws-cli/zsh_completion.sh | 17 +++++++++++++++++ 4 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 test/aws-cli/zsh_completion.sh diff --git a/src/aws-cli/devcontainer-feature.json b/src/aws-cli/devcontainer-feature.json index ed2e20284..75d24ca88 100644 --- a/src/aws-cli/devcontainer-feature.json +++ b/src/aws-cli/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "aws-cli", - "version": "1.1.3", + "version": "1.1.4", "name": "AWS CLI", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/aws-cli", "description": "Installs the AWS CLI along with needed dependencies. Useful for base Dockerfiles that often are missing required install dependencies like gpg.", diff --git a/src/aws-cli/install.sh b/src/aws-cli/install.sh index ba6861074..1f6af54bd 100755 --- a/src/aws-cli/install.sh +++ b/src/aws-cli/install.sh @@ -119,16 +119,14 @@ install() { ./aws/install - # kubectl bash completion + # AWS bash completion mkdir -p /etc/bash_completion.d cp ./scripts/vendor/aws_bash_completer /etc/bash_completion.d/aws - # kubectl zsh completion - if [ -e "${USERHOME}/.oh-my-zsh" ]; then - mkdir -p "${USERHOME}/.oh-my-zsh/completions" - cp ./scripts/vendor/aws_zsh_completer.sh "${USERHOME}/.oh-my-zsh/completions/_aws" - chown -R "${USERNAME}" "${USERHOME}/.oh-my-zsh" - fi + # AWS zsh completion + mkdir -p /usr/local/share/zsh/site-functions/ + cp ./scripts/vendor/aws_zsh_completer.sh /usr/local/share/zsh/site-functions/_aws + sed -i '1s/^/#compdef aws\n/' /usr/local/share/zsh/site-functions/_aws rm -rf ./aws } diff --git a/test/aws-cli/scenarios.json b/test/aws-cli/scenarios.json index 9dd703c27..f2577c0ff 100644 --- a/test/aws-cli/scenarios.json +++ b/test/aws-cli/scenarios.json @@ -4,5 +4,14 @@ "features": { "aws-cli": {} } + }, + "zsh_completion": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "common-utils": { + "installZsh": true + }, + "aws-cli": {} + } } } \ No newline at end of file diff --git a/test/aws-cli/zsh_completion.sh b/test/aws-cli/zsh_completion.sh new file mode 100644 index 000000000..ca08e077d --- /dev/null +++ b/test/aws-cli/zsh_completion.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +# Import test library for `check` command +source dev-container-features-test-lib + +# Check that the zsh completion file exists in the correct location +check "zsh completion file installed" test -f /usr/local/share/zsh/site-functions/_aws + +# Check that the completion file has the proper zsh completion header +check "zsh completion file has compdef header" grep -q "^#compdef aws" /usr/local/share/zsh/site-functions/_aws + +# Actual ZSH completion testing is a pain, so just ignoring it for now. + +# Report result +reportResults