-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.kshpwd
73 lines (70 loc) · 1.38 KB
/
.kshpwd
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
#
# .kshpwd - local stuff to abbreviate PWD...
#
#ident "@(#)HOME:.kshpwd 37.3 22/02/23 17:23:53 (woods)"
# This works entirely with global variables -- handling parameters is just more
# unnecessary overhead for this purpose
#
function pwd_to_banner
{
case "$PWD" in
${HOME})
# avoid the trailing slash, e.g.: sh://host/~/
BANNER_PWD='~'
;;
${HOME}/*)
BANNER_PWD='~'${PWD#$HOME}
;;
$(dirname ${HOME})/*)
BANNER_PWD='~'"${PWD#$(dirname $HOME)/}"
;;
/home/*)
BANNER_PWD='~'"${PWD#/home/}"
;;
"*/work?(.d)/${LOGNAME}/*")
BANNER_PWD='mywork:'"${PWD#*/work?(.d)/${LOGNAME}/}"
;;
"*/work?(.d)/*")
BANNER_PWD='work:'"${PWD#*/work?(.d)/}"
;;
/usr/src/*)
BANNER_PWD='src:'"${PWD#/usr/src/}"
;;
/usr/pkgsrc/*)
BANNER_PWD='pkgsrc:'"${PWD#/usr/pkgsrc/}"
;;
/usr/xsrc/*)
BANNER_PWD='xsrc:'"${PWD#/usr/xsrc/}"
;;
*)
# trim just the leading slash to avoid "sh://host//dir"
BANNER_PWD="${PWD#/}"
;;
esac
}
unalias cd 2>/dev/null
alias cd='_cd'
function _cd
{
if [ -n "$*" ]; then
\cd "$*"
else
# XXX "\cd ''" goes nowhere
\cd
fi
pwd_to_banner
if [ "$(ismpx)" = yes ] ; then
eval myxban -l "\"$MYXBAN_L\""
# there would be no point without setban, but we must test it anyway
elif type setban > /dev/null 2>&1 ; then
setban
fi
}
# make sure BANNER_PWD is now set as we want it,
# but _ONLY_ for interactive shells!
#
case "$0" in
-*)
cd .
;;
esac