annotate .shell.d/99.prompt.zsh @ 178:da329720ff18

zsh prompt: add urxvt to whitelisted terms, use a loop instead of many ifs
author Augie Fackler <durin42@gmail.com>
date Wed, 13 Jan 2010 10:28:44 -0600
parents 62bfb554ab85
children ebbbf3567a0e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1 # Magic prompt with colors
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
2 # username in blue if not root
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
3 # username in red if root - time in pink w/
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
4 # DANGER replacing the date
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
5 # failed jobs print exit status in the RPS1 with yellow text
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6 setopt prompt_subst
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
7
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
8 preexec () {
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
9 currJob="`echo $3 | cut -d ' ' -f 1 | head -n 1`"
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
10 if [[ "$TERM" == "screen" ]]; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
11 hostUser="%10<...<%~%<<"
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
12 print -Pn "\ek[$hostUser $currJob]\e\\"
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
13 else
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
14 if [[ "$FANCYTYPE" == "YES" ]]; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
15 hostUser="%n@%m: %2~"
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
16 print -Pn "\e]0;$hostUser [$currJob]\a"
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
17 fi
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
18 fi
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19 }
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
20
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
21 function right_side_prompt() {
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
22 branch=`vcs_current_branch`
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
23 if [ $? = 0 ] ; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24 echo -n $branch
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
25 else
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
26 date '+%D %H:%M'
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
27 fi
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
28 }
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
29
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
30 function precmd () {
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
31 rps_branch=`right_side_prompt`
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
32 }
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
33
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
34 if [ "x`whoami`" = "xroot" ] ; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
35 PS1=$'%{\e];%n@%m: %2~ [zsh]\a%}[%m:%3~] %{\e[31m%}%n%{\e[0m%}%# '
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
36 if [[ "$TERM" == "screen" ]] ; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
37 PS1=$'%{\ek[%2~ zsh]\e\\%}[%m:%3~] %{\e[31m%}%n%{\e[0m%}%# '
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
38 fi
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
39 RPS1=$'%{\e[1;35m%}[DANGER %t]%{\e[0m%}%(?..%{\e[1;33m%} %?%{\e[1;0m%})'
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
40 else
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
41 PS1=$'%{\e];%n@%m: %2~ [zsh]\a%}[%m:%3~] %{\e[34m%}%n%{\e[0m%}%# '
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
42 if [[ "$TERM" == "screen" ]]; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
43 PS1=$'%{\ek[%2~ zsh]\e\\%}[%m:%3~] %{\e[34m%}%n%{\e[0m%}%# '
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
44 fi
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
45 RPS1=$'[$rps_branch]%(?..%{\e[1;33m%} %?%{\e[0m%})'
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
46 fi
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
47
178
da329720ff18 zsh prompt: add urxvt to whitelisted terms, use a loop instead of many ifs
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
48
da329720ff18 zsh prompt: add urxvt to whitelisted terms, use a loop instead of many ifs
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
49 export FANCYTYPE="NO"
da329720ff18 zsh prompt: add urxvt to whitelisted terms, use a loop instead of many ifs
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
50
da329720ff18 zsh prompt: add urxvt to whitelisted terms, use a loop instead of many ifs
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
51 for ok in rxvt rxvt-unicode xterm xterm-color screen ; do
da329720ff18 zsh prompt: add urxvt to whitelisted terms, use a loop instead of many ifs
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
52 if [ "$TERM" = "$ok" ] ; then
da329720ff18 zsh prompt: add urxvt to whitelisted terms, use a loop instead of many ifs
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
53 export FANCYTYPE="YES"
da329720ff18 zsh prompt: add urxvt to whitelisted terms, use a loop instead of many ifs
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
54 fi
da329720ff18 zsh prompt: add urxvt to whitelisted terms, use a loop instead of many ifs
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
55 done
da329720ff18 zsh prompt: add urxvt to whitelisted terms, use a loop instead of many ifs
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
56
da329720ff18 zsh prompt: add urxvt to whitelisted terms, use a loop instead of many ifs
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
57 if [ $FANCYTYPE = "NO" ] ; then
da329720ff18 zsh prompt: add urxvt to whitelisted terms, use a loop instead of many ifs
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
58 prompt='[%m:%3~] %n%# '
da329720ff18 zsh prompt: add urxvt to whitelisted terms, use a loop instead of many ifs
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
59 RPS1=$'[%W %t]'
0
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
60 fi
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
61
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
62 #nonfancy no-frills prompt - disabled (same as the "non-fancy" one above)
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
63 #prompt='[%m:%3~] %n%# '
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
64 #RPS1=$'[%W %t]'