Skip to content

Instantly share code, notes, and snippets.

@jmaupetit
Last active May 3, 2016 10:30
Show Gist options
  • Save jmaupetit/118013f2b14fc11d1d61 to your computer and use it in GitHub Desktop.
Save jmaupetit/118013f2b14fc11d1d61 to your computer and use it in GitHub Desktop.
Watson Bash Prompt
# 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"
@jmaupetit
Copy link
Author

Here is an example result of watson status in your prompt:

1__bash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment