Last active
August 29, 2015 14:01
-
-
Save srid/a48d8b6b73cf6ebf5e6b to your computer and use it in GitHub Desktop.
stackato bash prompt
This file contains 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
#!/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}" |
This file contains 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
# 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