Skip to content

Instantly share code, notes, and snippets.

@BaylorRae
Created December 19, 2011 23:15
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BaylorRae/1499367 to your computer and use it in GitHub Desktop.
Save BaylorRae/1499367 to your computer and use it in GitHub Desktop.
This is my oh-my-zsh theme.
# 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%} '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment