SHARE
TWEET

Untitled

a guest Jul 23rd, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ENV=$1
  2.  
  3. RED='\[\033[1;31m\]'
  4. YELLOW='\[\033[1;33m\]'
  5. NC='\[\033[0m\]' # No Color
  6.  
  7.  if [[ "$OLD_PS1" == "" ]]; then
  8.     OLD_PS1="$PS1"
  9. fi
  10.  
  11.  # Unset AWS_* variables previously set from aws-vault. Do this via some janky bash to ensure it works.
  12. while read -r line; do unset $line; done < <(env | grep AWS_ | while read old_env_value; do
  13.     # take each AWS var and unset them, ex: 'AWS_REGION=us-east-1' turns into 'unset AWS_REGION'
  14.     env_var="$(echo $old_env_value | awk -F'=' '{print $1}')";
  15.     echo $env_var;
  16. done);
  17.  if [[ "${ENV}" != "clear-env" ]]; then
  18.     # Re-assign AWS_* variables from aws-vault.  Do this via some janky bash to ensure it works.
  19.     while read -r line; do declare -x "$line"; done < <(aws-vault exec ${ENV} -- env | grep AWS_)
  20.     # Export $PS1 so we know what we are doing.
  21.     if [[ "${ENV}" == "production" ]]; then
  22.         export PS1="[${RED}$ENV}${NC}] $OLD_PS1";
  23.     else
  24.         export PS1="[${YELLOW}${ENV}${NC}] $OLD_PS1";
  25.     fi
  26. else
  27.     if [[ "$OLD_PS1" != "" ]]; then
  28.         export PS1="$OLD_PS1";
  29.     fi
  30. Fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top