-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom_zsh_tabs.sh
58 lines (51 loc) · 929 Bytes
/
custom_zsh_tabs.sh
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
#! /bin/bash
function precmd {
setTitles $PWD
}
function setMainTitle {
echo -ne "\033]2;$(titleOrPWD $1)\007"
}
function setTabTitle {
echo -ne "\033]1;$(shortTitle $1)\007"
}
function setTitles {
if [ $2 ]; then
TITLE2=$2
else
TITLE2=$1
fi
setMainTitle $TITLE2
setTabTitle $1
}
function shortTitle {
COUNTER=0
TMP_TITLE=`titleOrPWD $1`
for word in $(echo $TMP_TITLE | tr "/" " "); do
let "COUNTER+=1"
APU_WORD=$PU_WORD
PU_WORD=$U_WORD
U_WORD=$word
done
#
if [ $COUNTER -lt '3' ]; then
TITLE=$TMP_TITLE
elif [ $APU_WORD = $USER ]; then
TITLE="~/$PU_WORD/$U_WORD"
elif [ $PU_WORD = $USER ]; then
TITLE="~/$U_WORD"
elif [ $U_WORD = $USER ]; then
TITLE='~'
else
TITLE=".../$PU_WORD/$U_WORD"
fi
echo "$TITLE"
}
function titleOrPWD {
if [ $1 ]; then
TITLE=$1
else
TITLE=$PWD
fi
echo $TITLE
}
echo 'Sourced custom_zsh_tabs.sh'