# A simple prompt based on https://github.com/isqua/bureau ASYNC_PROC=0 git_prompt="" _prompt_setup () { autoload -U colors && colors autoload -Uz vcs_info add-zsh-hook _prompt_git_staff add-zsh-hook precmd _prompt_precmd add-zsh-hook zshexit _prompt_exit PROMPT=$(_prompt) } _prompt () { local color=green if [ "$UID" = "0" ]; then color=red; fi _display_arrow } _prompt_git_staff() { zstyle ':vcs_info:*' enable git zstyle ':vcs_info:*' check-for-changes true zstyle ':vcs_info:*' max-exports 2 zstyle ':vcs_info:git*' stagedstr "%{$fg_bold[blue]%}●" zstyle ':vcs_info:git*' unstagedstr "%{$fg_bold[red]%}●" zstyle ':vcs_info:git*' formats "on %{$fg[blue]%}(%{$fg[red]%}%m%u%c%{$fg[yellow]%} %{$fg[magenta]%} %b%{$fg[blue]%})%{$reset_color%}" } _prompt_precmd() { local left="%{$fg[cyan]%}%c%{$reset_color%} $(_prompt_vcs_prompt &!)$git_prompt" print -P "\n${left}" if [[ "${ASYNC_PROC}" != 0 ]]; then kill -s HUP $ASYNC_PROC >/dev/null 2>&1 || : fi ASYNC_PROC=$! } _prompt_vcs_prompt () { vcs_info printf "%s" "$vcs_info_msg_0_" > "$(_prompt_temp_file)" kill -s USR1 $$ } _prompt_exit () { rm -f "$(_prompt_temp_file)" 2> /dev/null } _display_arrow() { echo "%(?:%{$fg_bold[green]%}➙ : %{$fg_bold[red]%}➙ %{$reset_color%})" } _prompt_string_width () { local str=$1 echo ${#${(S%%)str//(\%([KF1]|)\{*\}|\%[Bbkf])}} } _prompt_temp_file() { echo "/tmp/$(whoami)_zsh_rprompt.$$" } TRAPUSR1 () { git_prompt="$(cat $(_prompt_temp_file))" ASYNC_PROC=0 zle && zle .reset-prompt } function clear-scrollback-buffer { clear ASYNC_PROC=0 _prompt_precmd zle .reset-prompt && zle -R } zle -N clear-scrollback-buffer bindkey '^L' clear-scrollback-buffer _prompt_setup $@