ohmyzsh/themes/bira.zsh-theme
2015-11-21 22:01:02 +02:00

59 lines
1.5 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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
}