-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot.profile
139 lines (125 loc) · 3.34 KB
/
dot.profile
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#
# ~/.profile
#
# Determine shell
if test -n "${BASH_VERSION}" ; then
_sh=bash
elif test -n "${KSH_VERSION}" ; then
_sh=ksh93
elif test -n "${FCEDIT}" ; then
_sh=ksh
else
_sh=sh
fi
_is_cmd ()
{
command -v "$1" >/dev/null 2>&1
}
# Set PATH
if _is_cmd getconf ; then
_path="`getconf PATH`"
fi
# Add some directories to PATH if they exist
_path="${_path:+${_path}:}/bin:/usr/bin:/usr/local/bin"
_path="${_path}:/sbin:/usr/sbin:/usr/local/sbin"
_path="${_path}:/opt/freeware/bin" # for AIX
_path="${_path}:/usr/es/sbin/cluster/utilities" # for PowerHA
_path="${_path}:${HOME}/bin:${HOME}/.local/bin"
_path="${_path}:${PATH}"
# Check and remove duplicates
_ifs="${IFS}"
IFS=":"
for _p in ${_path} ; do
case ":${_npath}:" in
*":${_p}:"* ) ;;
* ) test -d "${_p}" && _npath="${_npath:+${_npath}:}${_p}" ;;
esac
done
IFS="${_ifs}"
PATH="${_npath}"
unset _path _npath _ifs _p
export PATH
# Set manpages path
if _is_cmd manpath ; then
# For Linux (which has manpath binary)
unset MANPATH
unset MANPATHISSET
else
MANPATH=/usr/share/man
# Add some directories to MANPATH if they exist
_manpath="/usr/local/man /usr/local/share/man"
_manpath="${_manpath} /opt/freeware/man /usr/opt/rpm/man" # for AIX
for _p in ${_manpath} ; do
test -d "${_p}" && MANPATH="${MANPATH}:${_p}"
done
unset _manpath _p
export MANPATH
fi
# Set terminal type
TERM="${TERM:-xterm}"
export TERM
# Set some variables if not set
if _is_cmd id ; then
test -n "${UID}" || UID="`id -ur 2>/dev/null`"
test -n "${EUID}" || EUID="`id -u 2>/dev/null`"
test -n "${USER}" || USER="`id -un 2>/dev/null`"
test -n "${LOGNAME}" || LOGNAME="${USER}"
test -n "${MAIL}" || MAIL="/var/spool/mail/${USER}"
test -n "${MAILMSG}" || MAILMSG="[YOU HAVE NEW MAIL]"
# Do NOT export UID, EUID, USER, and LOGNAME
export MAIL MAILMSG
fi
if _is_cmd hostname ; then
test -n "${HOSTNAME}" || HOSTNAME="`hostname`"
test -n "${HOST}" || HOST="${HOSTNAME}"
export HOST HOSTNAME
fi
# Set locale to POSIX for root
if test -n "${EUID}" && test "${EUID}" -eq 0 ; then
LC_ALL="C"
if _is_cmd locale ; then
# Little Linux hack
case " `locale -a` " in
*[[:space:]]"C.utf8"[[:space:]]* ) LC_ALL="C.UTF-8" ;;
esac
fi
export LC_ALL
fi
# Set XDG Base Directory variables
: "${XDG_CACHE_HOME:=${HOME}/.cache}"
: "${XDG_CONFIG_HOME:=${HOME}/.config}"
: "${XDG_DATA_HOME:=${HOME}/.local/share}"
: "${XDG_STATE_HOME:=${HOME}/.local/state}"
export XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_STATE_HOME
# Set other variables
TZ="Europe/Moscow"
EDITOR="vi"
export TZ EDITOR
# Set 'less' as PAGER if exist
if _is_cmd less ; then
PAGER="less"
LESS="-FMR"
export LESS
else
PAGER="more"
fi
export PAGER
# Source user environment file if exist
test -f "${HOME}/.env" && . "${HOME}/.env" || true
# Source appropriate .*shrc
if test "${_sh}" = "bash" ; then
_rc="${HOME}/.bashrc"
elif test "${_sh}" = "ksh" ; then
# ksh93 sets ENV variable and will source .kshrc after .profile
_rc="${HOME}/.kshrc"
else
_rc=""
fi
_inprofile="true" # Check this variable in rc
test -n "${_rc}" && test -f "${_rc}" && . "${_rc}" || true
unset _rc _inprofile
# Check mail at startup
test -n "${MAIL}" && test -s "${MAIL}" && echo "${MAILMSG}"
# Unset used local variables and functions
unset _sh
unset -f _is_cmd