Skip to content

Instantly share code, notes, and snippets.

@dylnuge
Created July 31, 2018 17:33
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 dylnuge/189e39c07c802753a9200869294b9978 to your computer and use it in GitHub Desktop.
Save dylnuge/189e39c07c802753a9200869294b9978 to your computer and use it in GitHub Desktop.
Extension to the Oh My Zsh Agnoster theme
prompt_timestamp() {
# Use timestamp to alert user that it's getting late. Time between 7 AM and
# 8 PM is shown in green. Time between 8 PM and 12 AM is shown in yellow. Time
# after 12 AM (but before 7 AM next morning) is shown in red.
currTime=`date +%k%m`
if [ $currTime -ge 700 -a $currTime -lt 2000 ]; then
prompt_segment default green '[%t]'
# Midnight is 0000, so can't compare with it easily
elif [ $currTime -ge 2000 -a $currTime -le 2359 ]; then
prompt_segment default yellow '[%t]'
else
prompt_segment default red '[%t]'
fi
}
build_rprompt() {
RETVAL=$?
prompt_timestamp
}
RPROMPT='%{%f%b%k%}$(build_rprompt) '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment