Mercurial > dotfiles
comparison .shell.d/99.prompt.zsh @ 39:62bfb554ab85
Reorganize zsh files so that bash can work as well.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Mon, 26 Jan 2009 13:21:00 -0600 |
parents | .zsh/99.prompt.zsh@c30d68fbd368 |
children | da329720ff18 |
comparison
equal
deleted
inserted
replaced
38:f70862dadf83 | 39:62bfb554ab85 |
---|---|
1 # Magic prompt with colors | |
2 # username in blue if not root | |
3 # username in red if root - time in pink w/ | |
4 # DANGER replacing the date | |
5 # failed jobs print exit status in the RPS1 with yellow text | |
6 setopt prompt_subst | |
7 | |
8 preexec () { | |
9 currJob="`echo $3 | cut -d ' ' -f 1 | head -n 1`" | |
10 if [[ "$TERM" == "screen" ]]; then | |
11 hostUser="%10<...<%~%<<" | |
12 print -Pn "\ek[$hostUser $currJob]\e\\" | |
13 else | |
14 if [[ "$FANCYTYPE" == "YES" ]]; then | |
15 hostUser="%n@%m: %2~" | |
16 print -Pn "\e]0;$hostUser [$currJob]\a" | |
17 fi | |
18 fi | |
19 } | |
20 | |
21 function right_side_prompt() { | |
22 branch=`vcs_current_branch` | |
23 if [ $? = 0 ] ; then | |
24 echo -n $branch | |
25 else | |
26 date '+%D %H:%M' | |
27 fi | |
28 } | |
29 | |
30 function precmd () { | |
31 rps_branch=`right_side_prompt` | |
32 } | |
33 | |
34 if [ "x`whoami`" = "xroot" ] ; then | |
35 PS1=$'%{\e];%n@%m: %2~ [zsh]\a%}[%m:%3~] %{\e[31m%}%n%{\e[0m%}%# ' | |
36 if [[ "$TERM" == "screen" ]] ; then | |
37 PS1=$'%{\ek[%2~ zsh]\e\\%}[%m:%3~] %{\e[31m%}%n%{\e[0m%}%# ' | |
38 fi | |
39 RPS1=$'%{\e[1;35m%}[DANGER %t]%{\e[0m%}%(?..%{\e[1;33m%} %?%{\e[1;0m%})' | |
40 else | |
41 PS1=$'%{\e];%n@%m: %2~ [zsh]\a%}[%m:%3~] %{\e[34m%}%n%{\e[0m%}%# ' | |
42 if [[ "$TERM" == "screen" ]]; then | |
43 PS1=$'%{\ek[%2~ zsh]\e\\%}[%m:%3~] %{\e[34m%}%n%{\e[0m%}%# ' | |
44 fi | |
45 RPS1=$'[$rps_branch]%(?..%{\e[1;33m%} %?%{\e[0m%})' | |
46 fi | |
47 | |
48 if [ "$TERM" = "rxvt" ] || [ "$TERM" = "xterm" ] \ | |
49 || [ "$TERM" = "xterm-color" ] || [ "$TERM" = "screen" ]; then | |
50 export FANCYTYPE="YES" | |
51 else | |
52 export FANCYTYPE="NO" | |
53 prompt='[%m:%3~] %n%# ' | |
54 RPS1=$'[%W %t]' | |
55 fi | |
56 | |
57 #nonfancy no-frills prompt - disabled (same as the "non-fancy" one above) | |
58 #prompt='[%m:%3~] %n%# ' | |
59 #RPS1=$'[%W %t]' |