-
Notifications
You must be signed in to change notification settings - Fork 1
/
.shpwd
60 lines (57 loc) · 1.32 KB
/
.shpwd
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
#
# .shpwd - local stuff to abbreviate PWD...
#
#ident "@(#)HOME:.shpwd 37.2 22/02/23 17:37:12 (woods)"
# this version is for ancient shells without ${variable%pattern} et al
#
# it works entirely with global variables -- handling parameters is just more
# unnecessary overhead for this purpose
#
pwd_to_banner()
{
case "${PWD}" in
${HOME})
# avoid the trailing slash, e.g.: sh://host/~/
BANNER_PWD='~'
;;
${HOME}/*)
BANNER_PWD='~'"`echo \"${PWD}\" | sed \"s|${HOME}||\"`"
;;
*)
# trim just the leading slash to avoid "sh://host//dir"
BANNER_PWD="`echo \"${PWD}\" | sed 's|^/||'`"
;;
esac
}
unset -f cd
cd ()
{
# note this has to support various ksh without chdir and/or weird
# "builtin" as $ENV won't be sourced until after .profile is finished,
# and we try "cd" at the end of this file...
#
if type chdir >/dev/null 2>&1; then
chdir ${1+"$@"}
elif type command >/dev/null 2>&1; then
command cd ${1+"$@"}
else
builtin cd ${1+"$@"}
fi
# assume $PWD is not maintained by the shell....
PWD=`pwd`
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 ; then
setban
fi
}
# make sure BANNER_PWD is now set as we want it,
# but _ONLY_ for login shells!
#
case "$0" in
-*)
cd .
;;
esac