Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
1a2d930b
Unverified
Commit
1a2d930b
authored
Mar 23, 2019
by
Marc Cornellà
Committed by
GitHub
Mar 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aws: refactor completion sourcing logic (#7364)
* Clean up Homebrew detection and add comments. Also changed some if flags. * Detect aws cli completion file from RPM
parent
83d11394
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
29 deletions
+27
-29
aws.plugin.zsh
plugins/aws/aws.plugin.zsh
+27
-29
No files found.
plugins/aws/aws.plugin.zsh
View file @
1a2d930b
_homebrew-installed
()
{
type
brew &> /dev/null
_xit
=
$?
if
[
$_xit
-eq
0
]
;
then
# ok , we have brew installed
# speculatively we check default brew prefix
if
[
-h
/usr/local/opt/awscli
]
;
then
_brew_prefix
=
"/usr/local/opt/awscli"
else
# ok , it is not 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
return
0
else
return
$_xit
fi
}
_awscli-homebrew-installed
()
{
[
-r
$_brew_prefix
/libexec/bin/aws_zsh_completer.sh
]
&> /dev/null
}
function
agp
{
function
agp
{
echo
$AWS_PROFILE
echo
$AWS_PROFILE
}
}
function
asp
{
function
asp
{
local
rprompt
=
${
RPROMPT
/<aws
:
$
(
agp
)
>/
}
local
rprompt
=
${
RPROMPT
/<aws
:
$
AWS_PROFILE
>/
}
export
AWS_DEFAULT_PROFILE
=
$1
export
AWS_DEFAULT_PROFILE
=
$1
export
AWS_PROFILE
=
$1
export
AWS_PROFILE
=
$1
...
@@ -39,11 +16,32 @@ function aws_profiles {
...
@@ -39,11 +16,32 @@ function aws_profiles {
}
}
compctl
-K
aws_profiles asp
compctl
-K
aws_profiles asp
if
which aws_zsh_completer.sh &>/dev/null
;
then
_aws_zsh_completer_path
=
$(
which aws_zsh_completer.sh 2>/dev/null
)
# Load awscli completions
elif
_homebrew-installed
&&
_awscli-homebrew-installed
;
then
_awscli-homebrew-installed
()
{
# check if Homebrew is installed
((
$+
commands[brew]
))
||
return
1
# speculatively check default brew prefix
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 if installed via Homebrew
if
[[
-z
$_aws_zsh_completer_path
]]
&&
_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
else
_aws_zsh_completer_path
=
/usr/share/zsh/site-functions/aws_zsh_completer.sh
fi
fi
[
-n
"
$_aws_zsh_completer_path
"
]
&&
[
-x
$_aws_zsh_completer_path
]
&&
source
$_aws_zsh_completer_path
[
[
-r
$_aws_zsh_completer_path
]
]
&&
source
$_aws_zsh_completer_path
unset
_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