diff --git a/Cargo.lock b/Cargo.lock index abcf58b..84c24ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -63,7 +63,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "awscredx" -version = "0.3.0" +version = "0.4.0" dependencies = [ "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 98a53cc..60b1876 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "awscredx" -version = "0.3.0" +version = "0.4.0" authors = ["Alexei Samokvalov "] edition = "2018" diff --git a/README.md b/README.md index da421f5..7049909 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/init/script.fish b/src/init/script.fish index 52176f5..314c8e1 100644 --- a/src/init/script.fish +++ b/src/init/script.fish @@ -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 diff --git a/src/init/script.sh b/src/init/script.sh index cb06a91..0a89e87 100644 --- a/src/init/script.sh +++ b/src/init/script.sh @@ -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