-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathS60_prompt
126 lines (104 loc) · 2.44 KB
/
S60_prompt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/zsh
#
# vi-mode colour changing
# http://www.zsh.org/mla/users/2006/msg01196.html
setopt prompt_subst
autoload colors
colors
rst="%{%b%s%u$reset_color%}"
bgc="%{%(?.$rst.%S)%}"
function lprompt {
local col1 col2 ch1 ch2
col1="%{%b$fg[$2]%}"
col2="%{$4$fg[$3]%}"
ch1=$col1${1[1]}
ch2=$col1${1[2]}
local git_b git_s col_b col_s
git_b='$(get_git_prompt_info '%b')'
git_s='$(get_git_prompt_info '%s')'
if [ -n "$TALIA_SHELL" ]; then talia_s=" [talia] " ; fi
if [ -n "$SSH_TTY" ]; then ssh_s="*" ; fi
col_s="%{$fg[red]%}"
PROMPT="\
$col2$ssh_s \
$bgc$ch1\
$bgc$col2%B%1~%b\
$col1 %n\
$col_s$talia_s\
$ch2$rst\
$col2\$$rst "
}
function _rprompt_dir {
local col_b col_s
git_p=${$(get_git_prompt_info '%p')%% }
col_p="%{$fg[yellow]%}"
local short
short="${PWD/$HOME/~}"
if test -z "$git_p" ; then
echo -n "$short"
return
fi
local lead rest
lead=$git_p
rest=${${short#$lead}#/}
echo -n "$lead$col_p/$rest"
}
function rprompt {
local col1 col2 ch1 ch2
col1="%{$fg[$2]%}"
col2="%{$4$fg[$3]%}"
ch1=$col1${1[1]}
ch2=$col1${1[2]}
col_git="%{$fg[green]%}"
col_rvm="%{$fg[blue]%}"
git_b='$(get_git_prompt_info '%b' )'
rvm_b='$(get_rvm_prompt_info '%b' )'
local _dir='$(_rprompt_dir)'
if [[ ( "$TERM" = "screen" ) && ( -n "$STY" ) ]]; then screen_s="screen:$STY[(ws:.:)-1] " ; fi
RPROMPT="\
$rst$ch1\
$col1$screen_s\
$col_git$git_b\
$col_rvm$rvm_b\
$col2%n@%m\
$col1:\
$col2%B$_dir%b\
$ch2$rst"
}
if [ $UID -eq 0 ]; then
lprompt '[]' red red
rprompt '[]' black black
elif [ "$TERM" = "screen" ]; then
lprompt '' green blue
rprompt '[]' blue black
elif [ -n "$SSH_TTY" ]; then
lprompt '' cyan blue
rprompt '[]' black black
else
lprompt '' blue black
rprompt '[]' black black
fi
unset rst bgc
# ------------------------------
# http://dotfiles.org/~frogb/.zshrc
case $TERM in
xterm* | rxvt* | urxvt*)
precmd() {
print -Pn "\e]0;%n@%m: %~\a"
}
preexec() {
#print -Pn "\e]0;$1\a"
print -Pn "\e]0;%n@%m: %~ $1\a"
}
;;
screen*)
precmd() {
print -nR $'\033k'"zsh"$'\033'\\\
print -nR $'\033]0;'"zsh"$'\a'
}
preexec() {
print -nR $'\033k'"$1"$'\033'\\\
print -nR $'\033]0;'"$1"$'\a'
}
;;
esac