Unverified Commit 1ef3d577 authored by Marc Cornellà's avatar Marc Cornellà Committed by GitHub
Browse files

aws: add support for AWS CLI v2 autocompletion (#8670)


Co-authored-by: default avatarMarc Cornellà <marc.cornella@live.com>
parent 2f345a3d
...@@ -62,7 +62,12 @@ fi ...@@ -62,7 +62,12 @@ fi
# Load awscli completions # Load awscli completions
function _awscli-homebrew-installed() { # AWS CLI v2 comes with its own autocompletion. Check if that is there, otherwise fall back
if [[ -x /usr/local/bin/aws_completer ]]; then
autoload -Uz bashcompinit && bashcompinit
complete -C aws_completer aws
else
function _awscli-homebrew-installed() {
# check if Homebrew is installed # check if Homebrew is installed
(( $+commands[brew] )) || return 1 (( $+commands[brew] )) || return 1
...@@ -74,13 +79,13 @@ function _awscli-homebrew-installed() { ...@@ -74,13 +79,13 @@ function _awscli-homebrew-installed() {
# this call to brew is expensive (about 400 ms), so at least let's make it only once # this call to brew is expensive (about 400 ms), so at least let's make it only once
_brew_prefix=$(brew --prefix awscli) _brew_prefix=$(brew --prefix awscli)
fi fi
} }
# get aws_zsh_completer.sh location from $PATH # get aws_zsh_completer.sh location from $PATH
_aws_zsh_completer_path="$commands[aws_zsh_completer.sh]" _aws_zsh_completer_path="$commands[aws_zsh_completer.sh]"
# otherwise check common locations # otherwise check common locations
if [[ -z $_aws_zsh_completer_path ]]; then if [[ -z $_aws_zsh_completer_path ]]; then
# Homebrew # Homebrew
if _awscli-homebrew-installed; then if _awscli-homebrew-installed; then
_aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh _aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh
...@@ -91,7 +96,8 @@ if [[ -z $_aws_zsh_completer_path ]]; then ...@@ -91,7 +96,8 @@ if [[ -z $_aws_zsh_completer_path ]]; then
else else
_aws_zsh_completer_path=/usr/share/zsh/site-functions/aws_zsh_completer.sh _aws_zsh_completer_path=/usr/share/zsh/site-functions/aws_zsh_completer.sh
fi fi
fi fi
[[ -r $_aws_zsh_completer_path ]] && source $_aws_zsh_completer_path [[ -r $_aws_zsh_completer_path ]] && source $_aws_zsh_completer_path
unset _aws_zsh_completer_path _brew_prefix unset _aws_zsh_completer_path _brew_prefix
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment