Mercurial > dotfiles
comparison .shell.d/99.prompt.zsh @ 382:491cd0cedeee
prompt: use async.zsh to avoid weird disowned process jank
| author | Augie Fackler <raf@durin42.com> |
|---|---|
| date | Thu, 10 Mar 2016 19:12:23 -0500 |
| parents | 0ceb8554801e |
| children | 2dd040318107 |
comparison
equal
deleted
inserted
replaced
| 381:e84b6da69ea0 | 382:491cd0cedeee |
|---|---|
| 19 } | 19 } |
| 20 | 20 |
| 21 PROMPT_TMP="${HOME}/.augie-zsh-tmp-prompt" | 21 PROMPT_TMP="${HOME}/.augie-zsh-tmp-prompt" |
| 22 | 22 |
| 23 function right_side_prompt() { | 23 function right_side_prompt() { |
| 24 cd $1 | |
| 24 branch=`vcs_current_branch` | 25 branch=`vcs_current_branch` |
| 25 if [ $? = 0 ] ; then | 26 if [ $? = 0 ] ; then |
| 26 echo -n $branch > "$PROMPT_TMP" | 27 print $branch |
| 27 kill -s USR1 $$ | |
| 28 fi | 28 fi |
| 29 } | 29 } |
| 30 | 30 |
| 31 function TRAPUSR1() { | 31 function right_prompt_results() { |
| 32 rps_branch=$(cat "$PROMPT_TMP") | 32 if [ $2 = 0 ] ; then |
| 33 zle && zle reset-prompt | 33 rps_branch=$3 |
| 34 } | 34 zle && zle reset-prompt |
| 35 | 35 fi |
| 36 function precmd () { | |
| 37 rps_branch="$(date '+%D %H:%M')" | |
| 38 right_side_prompt &! | |
| 39 } | 36 } |
| 40 | 37 |
| 41 if [ "x`whoami`" = "xroot" ] ; then | 38 if [ "x`whoami`" = "xroot" ] ; then |
| 42 PS1=$'%{\e];%n@%m: %2~ [zsh]\a%}[%m:%3~] %{\e[31m%}%n%{\e[0m%}%# ' | 39 PS1=$'%{\e];%n@%m: %2~ [zsh]\a%}[%m:%3~] %{\e[31m%}%n%{\e[0m%}%# ' |
| 43 if [[ "$TERM" == "screen" ]] ; then | 40 if [[ "$TERM" == "screen" ]] ; then |
| 70 # for tramp to not hang, need the following. cf: | 67 # for tramp to not hang, need the following. cf: |
| 71 # http://www.emacswiki.org/emacs/TrampMode | 68 # http://www.emacswiki.org/emacs/TrampMode |
| 72 unsetopt zle | 69 unsetopt zle |
| 73 unsetopt prompt_cr | 70 unsetopt prompt_cr |
| 74 unsetopt prompt_subst | 71 unsetopt prompt_subst |
| 75 unfunction precmd | |
| 76 unfunction preexec | 72 unfunction preexec |
| 73 else | |
| 74 autoload -Uz async && async | |
| 75 async_start_worker durin42_prompt -u -n | |
| 76 async_register_callback durin42_prompt right_prompt_results | |
| 77 | |
| 78 function precmd () { | |
| 79 rps_branch="$(date '+%D %H:%M')" | |
| 80 async_job durin42_prompt right_side_prompt $PWD | |
| 81 } | |
| 77 fi | 82 fi |
| 78 | 83 |
| 79 | 84 |
| 80 #nonfancy no-frills prompt - disabled (same as the "non-fancy" one above) | 85 #nonfancy no-frills prompt - disabled (same as the "non-fancy" one above) |
| 81 #prompt='[%m:%3~] %n%# ' | 86 #prompt='[%m:%3~] %n%# ' |
