Last active
May 3, 2016 10:30
-
-
Save jmaupetit/118013f2b14fc11d1d61 to your computer and use it in GitHub Desktop.
Watson 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
# Add this to your ~/.provile or ~/.bashrc depending on your system | |
# | |
# watson directory (require watson >= 1.3) | |
# This value is the default on MacOSX | |
WATSON_DIR="$HOME/Library/Application Support/watson" | |
watson_status() { | |
# colors taken from git-aware-prompt | |
# https://github.com/jimeh/git-aware-prompt | |
local txtred="$(tput setaf 1 2>/dev/null || echo '\e[0;31m')" # Red | |
local txtgrn="$(tput setaf 2 2>/dev/null || echo '\e[0;32m')" # Green | |
local txtrst="$(tput sgr 0 2>/dev/null || echo '\e[0m')" # Text Reset | |
# Started | |
local status="$txtgrn" | |
# Stopped | |
if [[ $(cat "$WATSON_DIR/state") == '{}' ]]; then | |
status="$txtred" | |
fi | |
echo -e "$status""◉""$txtrst" | |
} | |
# Add watson_status call to your prompt | |
PS1="\[\$(watson_status)\] \u@\h" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is an example result of
watson
status in your prompt: