Skip to content

Instantly share code, notes, and snippets.

@srid
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srid/a48d8b6b73cf6ebf5e6b to your computer and use it in GitHub Desktop.
Save srid/a48d8b6b73cf6ebf5e6b to your computer and use it in GitHub Desktop.
stackato bash prompt
#!/bin/bash -e
redis_hostport=$(cat /s/etc/kato/redis_uri | cut -d"/" -f3)
redis_host=$(echo $redis_hostport | cut -d: -f1)
redis_port=$(echo $redis_hostport | cut -d: -f2)
redis_cli="redis-cli -h ${redis_host} -p ${redis_port}"
user=$(whoami)
endpoint=$(timeout 0.1 $redis_cli get cluster | json endpoint)
ipaddr=$(timeout 0.1 /sbin/ifconfig eth0 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}')
roles=$(timeout 0.1 $redis_cli get node | json "[\"${ipaddr}\"]" | json roles | json -ak | paste -sd "," -)
# color
bldblk='\e[1;30m'
txtrst='\e[0m' # Text Reset
echo -e "${user}@${bldblk}${endpoint}${txtrst}:${ipaddr}:${roles}"
# run as:
# curlhttps://gist.githubusercontent.com/srid/a48d8b6b73cf6ebf5e6b/raw/4f9e228465b82817548ed5384236c291614698ad/install.sh | bash -
SCRIPT=/home/stackato/bash_prompt.sh
wget https://gist.githubusercontent.com/srid/a48d8b6b73cf6ebf5e6b/raw/393bb9e2dd4ff5b0f426b2d17fc66502ec6e2134/bash_prompt_sh -O $SCRIPT
chmod a+x $SCRIPT
echo "PROMPT_COMMAND=\"$SCRIPT\"" >> ~/.bashrc
echo "Installed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment