-
Notifications
You must be signed in to change notification settings - Fork 13
/
10_hooks
48 lines (41 loc) · 1.13 KB
/
10_hooks
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
# From: http://dotfiles.org/~_why/.zshrc
# Really works with minimal prompt setup.
short_hostname=$(hostname -s)
# format titles for screen and rxvt
function title() {
# escape '%' chars in $1, make nonprintables visible
a=${(V)1//\%/\%\%}
# Truncate command, and join lines.
a=$(print -Pn "%40>...>$a" | tr -d "\n")
case $TERM in
screen)
print -Pn "\ek($short_hostname) $a:$3\e\\" # screen title (in ^A")
;;
xterm*|rxvt|ansi)
print -Pn "\e]1;$2 | $a:$3\a" # plain xterm title
print -Pn "\e]2;$2 | $a:$3\a" # tab title
;;
esac
}
# precmd is called just before the prompt is printed
function precmd() {
# This may not be the best way of doing this.
if is-at-least 4.2.6
then
vcs_info_msg_0_=$(git-prompt)
elif [[ $git_enable == 1 ]]
then
vcs_info
else
vcs_info_msg_0_=''
fi
# This loads the info messgage into %1v.
title "zsh" "$USER@$short_hostname" "%55<...<%~"
}
# preexec is called just before any command line is executed
function preexec() {
title "$1" "$USER@$short_hostname" "%35<...<%~"
}
function postcmd() {
title "$1" "$USER@$short_hostname" "%35<...<%~"
}