Added my own theme, based on bira

Added a new theme based on bira and these async prompt
instructions, which adds the git status asynchronously, making it
significantly easier to work on huge repos (e.g. Chromium, WebKit).
This commit is contained in:
Yoav Weiss 2013-01-27 11:20:09 +01:00
commit c2011e55cd

View file

@ -0,0 +1,59 @@
# ZSH Theme - Preview: http://gyazo.com/8becc8a7ed5ab54a0262a470555c3eed.png
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
local user_host='%{$terminfo[bold]$fg[green]%}%n@%m%{$reset_color%}'
local current_dir='%{$terminfo[bold]$fg[blue]%} %~%{$reset_color%}'
local rvm_ruby=''
if which rvm-prompt &> /dev/null; then
rvm_ruby='%{$fg[red]%}$(rvm-prompt i v g)%{$reset_color%}'
else
if which rbenv &> /dev/null; then
rvm_ruby='%{$fg[red]%}$(rbenv version | sed -e "s/ (set.*$//")%{$reset_color%}'
fi
fi
setopt prompt_subst
PROMPT="╭ ${user_host} %t ${current_dir} ${rvm_ruby}
╰ %B$%b "
RPROMPT=""
RPS1="${return_code}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX=" %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="✔"
ZSH_THEME_GIT_PROMPT_DIRTY="✗"
ASYNC_PROC=0
function precmd() {
function async() {
# save to temp file
printf "%s" "$(git_prompt_info)" > "${HOME}/.zsh_tmp_prompt"
# signal parent
kill -s USR1 $$
}
# do not clear RPROMPT, let it persist
# kill child if necessary
if [[ "${ASYNC_PROC}" != 0 ]]; then
kill -s HUP $ASYNC_PROC >/dev/null 2>&1 || :
fi
# start background computation
async &!
ASYNC_PROC=$!
}
function TRAPUSR1() {
# read from temp file
PROMPT="╭ ${user_host} %t ${current_dir} ${rvm_ruby} $(cat ${HOME}/.zsh_tmp_prompt)
╰ %B$%b "
# reset proc number
ASYNC_PROC=0
# redisplay
zle && zle reset-prompt
}