Mercurial > dotfiles
comparison .shell.d/99.prompt.zsh @ 380:0ceb8554801e
zsh: make vcs info in prompt async
Roughly cribbed from [0], but I'm hoping to rework this soon to use
the zsh async library that shouldn't require a tempfile.
0: http://www.anishathalye.com/2015/02/07/an-asynchronous-shell-prompt/
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Thu, 10 Mar 2016 18:56:28 -0500 |
parents | 02b635053e8f |
children | 491cd0cedeee |
comparison
equal
deleted
inserted
replaced
379:0b8457903012 | 380:0ceb8554801e |
---|---|
16 print -Pn "\e]0;$hostUser [$currJob]\a" | 16 print -Pn "\e]0;$hostUser [$currJob]\a" |
17 fi | 17 fi |
18 fi | 18 fi |
19 } | 19 } |
20 | 20 |
21 PROMPT_TMP="${HOME}/.augie-zsh-tmp-prompt" | |
22 | |
21 function right_side_prompt() { | 23 function right_side_prompt() { |
22 branch=`vcs_current_branch` | 24 branch=`vcs_current_branch` |
23 if [ $? = 0 ] ; then | 25 if [ $? = 0 ] ; then |
24 echo -n $branch | 26 echo -n $branch > "$PROMPT_TMP" |
25 else | 27 kill -s USR1 $$ |
26 date '+%D %H:%M' | |
27 fi | 28 fi |
28 } | 29 } |
29 | 30 |
31 function TRAPUSR1() { | |
32 rps_branch=$(cat "$PROMPT_TMP") | |
33 zle && zle reset-prompt | |
34 } | |
35 | |
30 function precmd () { | 36 function precmd () { |
31 rps_branch=`right_side_prompt` | 37 rps_branch="$(date '+%D %H:%M')" |
38 right_side_prompt &! | |
32 } | 39 } |
33 | 40 |
34 if [ "x`whoami`" = "xroot" ] ; then | 41 if [ "x`whoami`" = "xroot" ] ; then |
35 PS1=$'%{\e];%n@%m: %2~ [zsh]\a%}[%m:%3~] %{\e[31m%}%n%{\e[0m%}%# ' | 42 PS1=$'%{\e];%n@%m: %2~ [zsh]\a%}[%m:%3~] %{\e[31m%}%n%{\e[0m%}%# ' |
36 if [[ "$TERM" == "screen" ]] ; then | 43 if [[ "$TERM" == "screen" ]] ; then |