Last active
April 15, 2019 12:07
-
-
Save chrisortman/1c6e3646ed36724bc6d15bb4eb224d89 to your computer and use it in GitHub Desktop.
Shell stuff for putting AWS context in my prompt (make sure jq is on your path)
This file contains hidden or 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
if .Account == "9999999" then "test" elif .Account == "111111" then "prod" else "" end |
This file contains hidden or 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
aws_prompt_info () { | |
local PID_FILE=~/.aws-login/default.pid | |
local IDENTITY_FILE=~/.aws-login/identity.txt | |
local FILTER_FILE=~/.oh-my-zsh/custom/aws_filter.jq | |
local PROF="" | |
if [[ -f "$PID_FILE" ]] | |
then | |
PROF=$( cat "$IDENTITY_FILE" 2>/dev/null || aws sts get-caller-identity | jq -r -f "$FILTER_FILE" | tee "$IDENTITY_FILE") | |
[[ -n "$PROF" ]] && echo "[$PROF]" | |
else | |
[[ -f "$IDENTITY_FILE" ]] && rm "$IDENTITY_FILE" | |
fi | |
} |
This file contains hidden or 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
# Depending on what you're using for a shell this will probably be different. In my shell I have my name instead of dude in case I forget it again | |
HOST_PROMPT_='%{$fg_bold[red]%}@dude$(aws_prompt_info) %{$fg_bold[cyan]%}%c ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment