Skip to content

Instantly share code, notes, and snippets.

@curtisallen
Last active December 11, 2015 05:28
Show Gist options
  • Save curtisallen/4552234 to your computer and use it in GitHub Desktop.
Save curtisallen/4552234 to your computer and use it in GitHub Desktop.
Curtis' oh-my-zsh theme
function toon {
echo -n "➜"
}
function collapse_pwd {
echo $(pwd | sed -e "s,^$HOME,~,")
}
get_git_dirty() {
git diff --quiet || echo '*'
}
# Threashold (sec) for showing cmd exec time
CMD_MAX_EXEC_TIME=3
# Displays the exec time of the last command if set threshold was exceeded
cmd_exec_time() {
local stop=`date +%s`
local start=${cmd_timestamp:-$stop}
let local elapsed=$stop-$start
[ $elapsed -gt $CMD_MAX_EXEC_TIME ] && echo ${elapsed}s
}
preexec() {
cmd_timestamp=`date +%s`
}
autoload -Uz vcs_info
autoload -U colors && colors
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' unstagedstr '%F{red}*' # display this when there are unstaged changes
zstyle ':vcs_info:*' stagedstr '%F{yellow}+' # display this when there are staged changes
zstyle ':vcs_info:*' actionformats \
'%F{5}%F{5}[%F{2}%b%F{3}|%F{1}%a%c%u%F{5}]%f '
zstyle ':vcs_info:*' formats \
'%F{5}%F{5}[%F{2}%b%c%u%F{5}]%f '
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
zstyle ':vcs_info:*' enable git cvs svn
theme_precmd () {
vcs_info
}
precmd() {
print -P '\n%{$fg[magenta]%}%n%{$reset_color%}@%{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[megenta]%}$(collapse_pwd) %{$reset_color%}${vcs_info_msg_0_}%{$reset_color%}%{$fg[yellow]%}$(cmd_exec_time)%{$reset_color%}'
# Reset value since `preexec` isn't always triggered
unset cmd_timestamp
}
setopt prompt_subst
#PROMPT='%{$fg[magenta]%}$(toon)%{$reset_color%} %~/ %{$reset_color%}${vcs_info_msg_0_}%{$reset_color%}'
#PROMPT='%{$fg[magenta]%}%n%{$reset_color%}@%{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[megenta]%}$(collapse_pwd) %{$reset_color%}${vcs_info_msg_0_}%{$reset_color%}%{$fg[red]%}$(toon)%{$reset_color%} '
PROMPT='%{$fg[red]%}$(toon)%{$reset_color%} '
autoload -U add-zsh-hook
add-zsh-hook precmd theme_precmd
@curtisallen
Copy link
Author

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