-
Notifications
You must be signed in to change notification settings - Fork 20
/
.zshprompt
108 lines (90 loc) · 2.83 KB
/
.zshprompt
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
# This used to be modified version of Phil's prompt,
# but now it is mostly unrecognizable.
#
# http://aperiodic.net/phil/prompt/
function precmd {
# make sure that all new commands are available
rehash
local HOST_DOTS
HOST_DOTS=`hostname | grep -o "\." | wc -l | sed 's/ *//'`
HOST_LEN=`expr $HOST_DOTS - 1`
# Only show user in the prompt if it isn't yourself
# Make sure and set the $ME var in .zshrc
[ -n "$ME" ] && [ $(whoami) != "$ME" ] && PR_IMPOSTER="(u:%n%)"
# Get Virtual Env
if [[ -n "$VIRTUAL_ENV" ]]; then
# Strip out the path and just leave the env name
VENV="(v:${VIRTUAL_ENV##*/})"
else
# In case you don't have one activated
VENV=''
fi
}
setopt extended_glob
# We'll take care of placing the venv name ourselves
export VIRTUAL_ENV_DISABLE_PROMPT=1
preexec () {
if [[ "$TERM" == "screen" ]]; then
local CMD=${1[(wr)^(*=*|sudo|-*)]}
echo -n "\ek$CMD\e\\"
fi
}
setprompt () {
# Need this so the prompt will work.
setopt prompt_subst
PR_NO_COLOUR="%{$terminfo[sgr0]%}"
# Test to see if the git prompt should show
[ -z "$PR_SHOW_GIT" ] && PR_GIT_STATUS=
# See if we can use extended characters to look nicer.
# More info about these characters in the VT100 user guide
# http://vt100.net/docs/vt100-ug/table3-9.html
typeset -A altchar
set -A altchar ${(s..)terminfo[acsc]}
PR_SET_CHARSET="%{$terminfo[enacs]%}"
PR_SHIFT_IN="%{$terminfo[smacs]%}"
PR_SHIFT_OUT="%{$terminfo[rmacs]%}"
PR_HBAR=${altchar[q]:--}
PR_VBAR=${altchar[x]:--}
PR_ULCORNER=${altchar[l]:--}
PR_LLCORNER=${altchar[m]:--}
PR_LRCORNER=${altchar[j]:--}
PR_URCORNER=${altchar[k]:--}
# Decide if we need to set titlebar text.
case $TERM in
xterm*)
PR_TITLEBAR=$'%{\e]0;%m $PR_IMPOSTER\a%}'
;;
screen)
PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %m $PR_IMPOSTER\e\\%}'
;;
*)
PR_TITLEBAR=''
;;
esac
# Decide whether to set a screen title
if [[ "$TERM" == "screen" ]]; then
PR_STITLE=$'%{\ekzsh\e\\%}'
else
PR_STITLE=''
fi
# Finally, the prompt (removed the color - claytron)
PROMPT='
$PR_SET_CHARSET\
$PR_STITLE${(e)PR_TITLEBAR}\
$PR_SHIFT_IN$PR_ULCORNER$PR_HBAR$PR_SHIFT_OUT\
%T %D{%a, %b %d} \
$PR_SHIFT_IN$PR_HBAR$PR_HBAR$PR_SHIFT_OUT\
%d \
$PR_SHIFT_IN$PR_HBAR$PR_HBAR$PR_URCORNER$PR_SHIFT_OUT\
$PR_SHIFT_IN$PR_VBAR$PR_SHIFT_OUT\
$PR_IMPOSTER$VENV$(git_super_status)\
$PR_SHIFT_IN$PR_LLCORNER$PR_HBAR$PR_SHIFT_OUT\
%${HOST_LEN}m%# \
$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT '
RPROMPT=''
PS2='$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT(\
%_)$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT '
}
setprompt