Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Oh My Zsh
Commits
1ef3d577
Unverified
Commit
1ef3d577
authored
Mar 05, 2020
by
Marc Cornellà
Committed by
GitHub
Mar 05, 2020
Browse files
aws: add support for AWS CLI v2 autocompletion (#8670)
Co-authored-by:
Marc Cornellà
<
marc.cornella@live.com
>
parent
2f345a3d
Changes
1
Hide whitespace changes
Inline
Side-by-side
plugins/aws/aws.plugin.zsh
View file @
1ef3d577
...
@@ -62,36 +62,42 @@ fi
...
@@ -62,36 +62,42 @@ 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
# check if Homebrew is installed
if
[[
-x
/usr/local/bin/aws_completer
]]
;
then
((
$+
commands[brew]
))
||
return
1
autoload
-Uz
bashcompinit
&&
bashcompinit
complete
-C
aws_completer aws
# speculatively check default brew prefix
else
if
[
-h
/usr/local/opt/awscli
]
;
then
function
_awscli-homebrew-installed
()
{
_brew_prefix
=
/usr/local/opt/awscli
# check if Homebrew is installed
else
((
$+
commands[brew]
))
||
return
1
# ok, it is not in the default prefix
# this call to brew is expensive (about 400 ms), so at least let's make it only once
# speculatively check default brew prefix
_brew_prefix
=
$(
brew
--prefix
awscli
)
if
[
-h
/usr/local/opt/awscli
]
;
then
_brew_prefix
=
/usr/local/opt/awscli
else
# ok, it is not in the default prefix
# this call to brew is expensive (about 400 ms), so at least let's make it only once
_brew_prefix
=
$(
brew
--prefix
awscli
)
fi
}
# get aws_zsh_completer.sh location from $PATH
_aws_zsh_completer_path
=
"
$commands
[aws_zsh_completer.sh]"
# otherwise check common locations
if
[[
-z
$_aws_zsh_completer_path
]]
;
then
# Homebrew
if
_awscli-homebrew-installed
;
then
_aws_zsh_completer_path
=
$_brew_prefix
/libexec/bin/aws_zsh_completer.sh
# Ubuntu
elif
[[
-e
/usr/share/zsh/vendor-completions/_awscli
]]
;
then
_aws_zsh_completer_path
=
/usr/share/zsh/vendor-completions/_awscli
# RPM
else
_aws_zsh_completer_path
=
/usr/share/zsh/site-functions/aws_zsh_completer.sh
fi
fi
fi
}
# get aws_zsh_completer.sh location from $PATH
[[
-r
$_aws_zsh_completer_path
]]
&&
source
$_aws_zsh_completer_path
_aws_zsh_completer_path
=
"
$commands
[aws_zsh_completer.sh]"
unset
_aws_zsh_completer_path _brew_prefix
# otherwise check common locations
if
[[
-z
$_aws_zsh_completer_path
]]
;
then
# Homebrew
if
_awscli-homebrew-installed
;
then
_aws_zsh_completer_path
=
$_brew_prefix
/libexec/bin/aws_zsh_completer.sh
# Ubuntu
elif
[[
-e
/usr/share/zsh/vendor-completions/_awscli
]]
;
then
_aws_zsh_completer_path
=
/usr/share/zsh/vendor-completions/_awscli
# RPM
else
_aws_zsh_completer_path
=
/usr/share/zsh/site-functions/aws_zsh_completer.sh
fi
fi
fi
[[
-r
$_aws_zsh_completer_path
]]
&&
source
$_aws_zsh_completer_path
unset
_aws_zsh_completer_path _brew_prefix
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment