Skip to content

Commit

Permalink
Show AWS_PROFILE in shell prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
sam701 committed Oct 14, 2019
1 parent 980f299 commit b76046a
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "awscredx"
version = "0.3.0"
version = "0.4.0"
authors = ["Alexei Samokvalov <[email protected]>"]
edition = "2018"

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Assume AWS roles under the motto "don't make me think".
`awscredx` has a goal to make the role assumption on the command line simple and intuitive.

## How to use it
Install it by calling `awscredx init`.
Download the [binary](https://github.com/sam701/awscredx/releases/latest).
Add `awscredx` into your `PATH` and call `awscredx init`.
It will print what it has done.

TODO: add a screenshot
Expand Down
23 changes: 23 additions & 0 deletions src/init/script.fish
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,35 @@
# Do not edit.

set -x AWSCREDX_SCRIPT_VERSION "@version@"
functions -c fish_prompt _original_fish_prompt


if test -e $HOME/.config/fish/functions/fish_prompt.fish
cat $HOME/.config/fish/functions/fish_prompt.fish | grep AWS_PROFILE > /dev/null
if test $status -eq 0
set _original_prompt_has_aws_profile 1
end
end

function assume
set -l output ("@bin@" assume $argv)
set -l s $status
if test $s -eq 0
eval "$output"
if test -z "$_original_prompt_has_aws_profile"
function fish_prompt
set -l old_status $status

echo -n "["
set_color brmagenta
echo -n $AWS_PROFILE
set_color normal
echo -n "] "

echo -n "exit $old_status" | .
_original_fish_prompt
end
end
else
return $s
end
Expand Down
2 changes: 2 additions & 0 deletions src/init/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
# Do not edit.

export AWSCREDX_SCRIPT_VERSION="@version@"
_ORIGINAL_PS1="${PS1:-}"
function assume {
out=$("@bin@" assume "$@")
s=$?
if [[ $s == 0 ]]; then
$out
PS1="[\e[1;35m$AWS_PROFILE\e[m] ${_ORIGINAL_PS1:-}"
else
return $s
fi
Expand Down

0 comments on commit b76046a

Please sign in to comment.