public
Created

This is my oh-my-zsh theme.

  • Download Gist
baylorrae.zsh-theme
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
# Baylor Rae's Prompt Theme
# based on wunjo prompt theme and modified for oh-my-zsh
 
# shows me all files and folders when I change directories
cd() { builtin cd "$@"; ls }
 
# uses ~ instead of /Users/baylorrae/
pwd() { print -D $PWD }
 
# I substituted my own so the commit times were live
my_git_info() {
# Make sure we're in a git repo
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
# Get the times
now=$(date +%s)
last_commit=$(git log --pretty=format:'%at' -1)
seconds_since_last_commit=$((now-last_commit))
minutes_since_last_commit=$((seconds_since_last_commit/60))
# Colorize the times
# green = < 10min
# yellow = < 30min
# red = > 30min
if [ "$minutes_since_last_commit" -gt 30 ]; then
colored_time="%{$fg[red]%}"
elif [ "$minutes_since_last_commit" -gt 10 ]; then
colored_time="%{$fg[yellow]%}"
else
colored_time="%{$fg[green]%}"
fi
 
# Add the minutes and reset color
colored_time+="%{$minutes_since_last_commit%}m"
colored_time+="%{$reset_color%}"
# Add the colored git branch
colored_branch="%{$fg[cyan]%}${ref#refs/heads/}%{$reset_color%}"
# Add it to the prompt
echo " ($colored_branch|$colored_time)"
}
 
PROMPT='%{$fg[green]%}%m%{$reset_color%}:${PWD/#$HOME/~}$(my_git_info) %{$fg[yellow]%}$%{$reset_color%} '

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.