Created
January 28, 2017 00:39
-
-
Save elerch/d76c8f5935da13ec5a7889417e35b84f to your computer and use it in GitHub Desktop.
Optimized version for my machine - branched from oh-my-zsh https://github.com/robbyrussell/oh-my-zsh/blob/7a63ccabf662138777a43d014a1a0ab5d8f86ab0/plugins/aws/aws.plugin.zsh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_homebrew-installed() { | |
type brew &> /dev/null | |
} | |
_awscli-homebrew-installed() { | |
brew list awscli &> /dev/null | |
} | |
export AWS_HOME=~/.aws | |
function agp { | |
echo $AWS_DEFAULT_PROFILE | |
} | |
function asp { | |
local rprompt=${RPROMPT/<aws:$(agp)>/} | |
export AWS_DEFAULT_PROFILE=$1 | |
export AWS_PROFILE=$1 | |
export RPROMPT="<aws:$AWS_DEFAULT_PROFILE>$rprompt" | |
} | |
function aws_profiles { | |
reply=($(grep profile $AWS_HOME/config|sed -e 's/.*profile \([a-zA-Z0-9_-]*\).*/\1/')) | |
} | |
compctl -K aws_profiles asp | |
# This is the default install location for homebrew. brew and | |
# brew list are very slow, so we'll check the default path first | |
if [ -f "/usr/local/opt/awscli/libexec/bin/aws_zsh_completer.sh" ]; then | |
_aws_zsh_completer_path="/usr/local/opt/awscli/libexec/bin/aws_zsh_completer.sh" | |
elif _homebrew-installed && _awscli-homebrew-installed ; then | |
_aws_zsh_completer_path=$(brew --prefix awscli)/libexec/bin/aws_zsh_completer.sh | |
else | |
_aws_zsh_completer_path=$(which aws_zsh_completer.sh) | |
fi | |
[ -x $_aws_zsh_completer_path ] && source $_aws_zsh_completer_path | |
unset _aws_zsh_completer_path |
Yeah - this falls back to $(which aws_zsh_completer.sh), which will pick up /usr/local/bin. The issue is that running brew --prefix in login scripts is brutally slow, so I'm hardcoding the common paths to avoid calling brew. It's mac specific and will be ignored on other platforms.
Thanks for this. I was finally able to reduce oh-my-zsh startup time by a couple of seconds. It had been haunting me for a good year+.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For me it's at
/usr/local/bin/aws_zsh_completer.sh
. I just installed oh-my-zsh from scratch, so maybe that's the current default location..