Mercurial > dotfiles
annotate .shell.d/99.prompt.zsh @ 307:e37b00236907
zshrc: work around my shell function that turns on utf8 in screen
The zsh built in which was getting confused by the function, and
always claimed screen was installed. I'm finally running into machines
with tmux but not screen, so I noticed.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Sat, 19 Jan 2013 19:29:58 -0600 |
parents | 02b635053e8f |
children | 0ceb8554801e |
rev | line source |
---|---|
0 | 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 () { | |
179 | 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 | |
0 | 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 | |
179 | 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%})' | |
0 | 40 else |
179 | 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 | |
0 | 45 RPS1=$'[$rps_branch]%(?..%{\e[1;33m%} %?%{\e[0m%})' |
46 fi | |
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 |
272
02b635053e8f
zsh prompt: allow fancy prompt mode on xterm-256color as well
Augie Fackler <durin42@gmail.com>
parents:
182
diff
changeset
|
51 for ok in rxvt rxvt-unicode xterm xterm-256color xterm-color screen ; do |
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
|
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 | 60 fi |
61 | |
182
e189dfb33bfa
zsh prompt: unset basically everything if in tramp
Augie Fackler <durin42@gmail.com>
parents:
179
diff
changeset
|
62 if [[ $TERM == "dumb" ]]; then # in emacs |
e189dfb33bfa
zsh prompt: unset basically everything if in tramp
Augie Fackler <durin42@gmail.com>
parents:
179
diff
changeset
|
63 # for tramp to not hang, need the following. cf: |
e189dfb33bfa
zsh prompt: unset basically everything if in tramp
Augie Fackler <durin42@gmail.com>
parents:
179
diff
changeset
|
64 # http://www.emacswiki.org/emacs/TrampMode |
e189dfb33bfa
zsh prompt: unset basically everything if in tramp
Augie Fackler <durin42@gmail.com>
parents:
179
diff
changeset
|
65 unsetopt zle |
e189dfb33bfa
zsh prompt: unset basically everything if in tramp
Augie Fackler <durin42@gmail.com>
parents:
179
diff
changeset
|
66 unsetopt prompt_cr |
e189dfb33bfa
zsh prompt: unset basically everything if in tramp
Augie Fackler <durin42@gmail.com>
parents:
179
diff
changeset
|
67 unsetopt prompt_subst |
e189dfb33bfa
zsh prompt: unset basically everything if in tramp
Augie Fackler <durin42@gmail.com>
parents:
179
diff
changeset
|
68 unfunction precmd |
e189dfb33bfa
zsh prompt: unset basically everything if in tramp
Augie Fackler <durin42@gmail.com>
parents:
179
diff
changeset
|
69 unfunction preexec |
e189dfb33bfa
zsh prompt: unset basically everything if in tramp
Augie Fackler <durin42@gmail.com>
parents:
179
diff
changeset
|
70 fi |
e189dfb33bfa
zsh prompt: unset basically everything if in tramp
Augie Fackler <durin42@gmail.com>
parents:
179
diff
changeset
|
71 |
e189dfb33bfa
zsh prompt: unset basically everything if in tramp
Augie Fackler <durin42@gmail.com>
parents:
179
diff
changeset
|
72 |
0 | 73 #nonfancy no-frills prompt - disabled (same as the "non-fancy" one above) |
74 #prompt='[%m:%3~] %n%# ' | |
75 #RPS1=$'[%W %t]' |