Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env bash
SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}"
SCM_THEME_PROMPT_PREFIX=" |"
SCM_THEME_PROMPT_SUFFIX="${green}|"
GIT_THEME_PROMPT_DIRTY=" ${red}"
GIT_THEME_PROMPT_CLEAN=" ${bold_green}"
GIT_THEME_PROMPT_PREFIX=" ${green}|"
GIT_THEME_PROMPT_SUFFIX="${green}|"
CONDAENV_THEME_PROMPT_SUFFIX="|"
WATER_TIME=${WATER_TIME:-1200} # Set time interval in seconds
DRINK_WATER_CONF="${DRINK_WATER_CONF:-$HOME/.water}"
REST_THINGS=(🏇 🏌️ 🏋️ ⛹️ ⛷ 🎤 🏓 🏸 🎱 🎯 )
drink_water() {
# If the file doesn't exist, create it
if [ ! -f $DRINK_WATER_CONF ]; then
date +%s > $DRINK_WATER_CONF
fi
# Tail is used to remain compatible with the pervious file format
next_time=$(($(tail -1 $DRINK_WATER_CONF) + $WATER_TIME))
if [ $next_time -lt $(date +%s) ]; then
rest_thing=${REST_THINGS[$(( ( RANDOM % 10 ) + 1 ))]}
echo -n "Go get some 💧 and take a rest $rest_thing"
fi
}
not_thirsty() {
date +%s > $DRINK_WATER_CONF
echo "Water is essential"
}
not_tired() {
date +%s > $DRINK_WATER_CONF
take-a-rest && echo "I'm energy"
}
next_drink() {
next_time=$(($(cat $DRINK_WATER_CONF) + $WATER_TIME))
next_date=""
# Mac's date command uses a different flag
case "$(uname)" in
'Darwin')
next_date="$(date -r $next_time)"
;;
*)
next_date="$(date --date="@$next_time")"
;;
esac
echo "Next drink at $next_date"
}
function prompt_command() {
PS1="\n${red}$(drink_water) ${yellow}$(python_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}${reset_color} "
}
safe_append_prompt_command prompt_command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment