-
Notifications
You must be signed in to change notification settings - Fork 1
/
.env
298 lines (251 loc) · 10.1 KB
/
.env
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
#------------------------------------------------------------------------#
# common stuff for ksh & bash #
#------------------------------------------------------------------------#
CURRENT_OS=$(uname -s)
CURRENT_SHORT_HOST=$(hostname | sed "s/\..*//g")
CURRENT_OS_BITS=$(uname -r | grep -c x86_64)
if [ "$CURRENT_OS_BITS" == "1" ]; then
CURRENT_OS_BITS="64bit"
else
CURRENT_OS_BITS="32bit"
fi
export CURRENT_OS CURRENT_SHORT_HOST CURRENT_OS_BITS
#NO_ENV_PATH=$NO_ENV_PATH:/home/patrice/tools/bin
#NO_ENV_PATH=$NO_ENV_PATH:${HOME}/.vnc:${HOME}/bin
#determine location
if [ "$CURRENT_OS" == "SunOS" ]; then
CURRENT_SERVER_IP=`/sbin/ifconfig -a | grep e1000 -A1 | grep "inet " | cut -d " " -f2 | cut -d " " -f1`
elif [ "$CURRENT_OS" == "Linux" ]; then
CURRENT_SERVER_IP=`/sbin/ifconfig | grep eth0 -A1 | grep "inet addr" | cut -d ":" -f2 | cut -d " " -f1`
fi
CURRENT_LOCATION=ba
if [[ "$CURRENT_SERVER_IP" =~ "172.31" ]]; then
CURRENT_LOCATION=an
elif [[ "$CURRENT_SERVER_IP" =~ "135.247" ]]; then
CURRENT_LOCATION=ba
elif [[ "$CURRENT_SERVER_IP" =~ "135.1" ]]; then
CURRENT_LOCATION=ih
fi
export CURRENT_SERVER_IP CURRENT_LOCATION
NO_ENV_PATH=$HOME/apps/bin
if [ "$CURRENT_OS" == "SunOS" ]; then
#home folder binaries
NO_ENV_PATH=$NO_ENV_PATH:$HOME/bin_sol:$HOME/bin:$HOME/bin_private:$HOME/usr/bin:$HOME/usr/local/bin
#GNU tools (grep, cscope, bash, ...)
NO_ENV_PATH=$NO_ENV_PATH:/opt/exp/bin:/opt/exp/gnu/bin
#common bin folders
NO_ENV_PATH=$NO_ENV_PATH:/bin:/usr/bin:/usr/sbin:/usr/local/bin
#miscellaneous stuff (/etc)
NO_ENV_PATH=$NO_ENV_PATH:/usr/dt/bin
NO_ENV_PATH=$NO_ENV_PATH:/opt/unison/bin:/opt/csw/bin:/usr/openwin/bin
NO_ENV_PATH=$NO_ENV_PATH:/opt/x11r6/tk-tcl/bin:/opt/x11r6/bin:/opt/x11r6/jdk/jdk1.1.5/bin
MANPATH=/usr/man:/usr/share/man:$HOME/usr/local/share/man:/opt/SUNWwabi/man:/usr/dt/man:/usr/umts/man
BLD_LD_LIBRARY_PATH=/opt/lsf/5.0/sparc-sol7-64/lib
LD_LIBRARY_PATH=/usr/lib:/usr/openwin/lib:$BLD_LD_LIBRARY_PATH
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/x11r6/lib:/usr/dt/lib
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/x11r6/tk-tcl/lib/itcl:/opt/x11r6/tk-tcl/lib
elif [ "$CURRENT_OS" == "Linux" ]; then
#NX client/server
NO_ENV_PATH=$NO_ENV_PATH:/usr/NX/bin
#potential 64bit $HOME/bin_64 folder
if [ "$CURRENT_OS_BITS" == "64bit" ]; then
#64-bit home folder binaries
NO_ENV_PATH=$NO_ENV_PATH:$HOME/bin_64
fi
#home folder binaries
NO_ENV_PATH=$NO_ENV_PATH:$HOME/bin:$HOME/bin_private:$HOME/usr/bin:$HOME/usr/local/bin
#srlinux binaries
NO_ENV_PATH=$NO_ENV_PATH:/opt/srlinux/usr/bin:/opt/srlinux/usr/local/bin
#timostools
NO_ENV_PATH=$NO_ENV_PATH:/usr/local/timostools
#common bin folders
NO_ENV_PATH=$NO_ENV_PATH:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
#common Linux folders
NO_ENV_PATH=$NO_ENV_PATH:/usr/lib64/qt-3.3/bin
#global bin
NO_ENV_PATH=$NO_ENV_PATH:/usr/global/bin
MANPATH=/usr/share/man:$HOME/apps/share/man
INFOPATH=/usr/share/info:$HOME/apps/share/info
PERL5LIB=
PYTHONPATH=
AWKPATH=.:$HOME/apps/share/awk/:/usr/local/share/awk
#newer GCC 10.2.0 and CLANG 14.0.0
NO_ENV_PATH=$HOME/toolchains/gcc/bin:$HOME/toolchains/llvm/bin:$NO_ENV_PATH
#beware of adding $HOME/apps/lib to LD_LIBRARY_PATH
#NX sessions crash few seconds after connecting (different version of libz problem ???)
LD_LIBRARY_PATH=$HOME/toolchains/gcc/lib64:$HOME/toolchains/llvm/lib:/usr/lib:/usr/local/lib64:/usr/local/lib:$HOME/apps/lib:$HOME/apps/lib64
#since we are using custom build of pkg-config the default search folders are pointing to the custom install lib/share folders,
# however many packages are installed via system rpm installs and so pkg-config needs to be able to scan those system folders as well
export PKG_CONFIG_PATH=/usr/lib64/pkgconfig:/usr/share/pkgconfig:$HOME/apps/lib64/pkgconfig
else
echo "Unknown OS: $CURRENT_OS (PATH and MANPATH will be left untouched)"
NO_ENV_PATH=$PATH
fi
export NO_ENV_PATH MANPATH
export AWKPATH
export BLD_LD_LIBRARY_PATH LD_LIBRARY_PATH
#finalize path
export PATH=$NO_ENV_PATH:$ENV_PATH
#export LANG=en_US.utf8
#export LC_ALL=en_US.utf8
#export LC_CTYPE=en_US.utf8
#------------------------------------------------------------------------#
# basic path for tools, echo and shell. #
#------------------------------------------------------------------------#
export TOOL_BASEDIR=/opt
#no change in ls or grep in unknown OS
if [ "$CURRENT_OS" == "SunOS" ]; then
export LS=/opt/exp/gnu/bin/ls
export GREP=/opt/exp/gnu/bin/grep
elif [ "$CURRENT_OS" == "Linux" ]; then
export LS=`/usr/bin/which ls`
export GREP=`/usr/bin/which grep`
fi
#------------------------------------------------------------------------#
# environment preferences: EDITOR, PROMPT, etc. #
#------------------------------------------------------------------------#
export VIM=$HOME/apps/share/vim
export EDITOR=vim
export PAGER=less
export ED=$EDITOR
export VISUAL=$EDITOR
# setup OS dependent executables and variables once
if [ -z "$OS_DEPENDENT_SETTINGS_DONE" ]; then
# link to correct manpager based on the man version
if man --version 2>&1 | grep -q man,; then
#export MANPAGER="env MAN_PN=1 vx -M +MANPAGER -"
#export MANPAGER='col -bx | vx -c ":set ft=man nonu norelativenumber nolist titlestring=MANPAGE" -R -'
#works well for CentOS6 with old man 1.x.y:
export MANPAGER='col -bx | env MAN_PN=1 vim --noplugin -c ":set ft=man nonu nolist titlestring=MANPAGE | if v:version >= 703 | set norelativenumber | endif" -R -M -'
else
#newer man 2.x (CentOS7) supports this:
# export MANPAGER="vim -c MANPAGER -"
export MANPAGER='env MAN_PN=1 vim -c MANPAGER -c "set nonumber | if v:version >= 703 | set norelativenumber | endif | if exists(\"+signcolumn\") | set signcolumn=no | endif" -'
fi
export OS_DEPENDENT_SETTINGS_DONE=1
fi
export ENV=$HOME/.env
export SYSTEM="`uname -n`"
export XHOME=/opt/x11r6/bin
#isn't this already by default ?
#stty intr "^C"
#reset SHELL
kshpath=/opt/ksh93r/bin/ksh
if [ ! -x $kshpath ]; then
kshpath=/bin/ksh93r
fi
if [ ! -x $kshpath ]; then
kshpath=/bin/ksh93
fi
if [ ! -x $kshpath ]; then
kshpath=/bin/ksh
fi
if [ ! -x $kshpath ]; then
kshpath=/bin/sh
fi
export SHELL=$kshpath
#reset history file
export HISTFILE=~/.ksh_history
export HISTSIZE=200
#reset term type
export TERMINFO=~/.terminfo
#no change in TERM on Unknown OS
if [ "$CURRENT_OS" == "SunOS" ]; then
export TERM=xterm256
elif [ "$CURRENT_OS" == "Linux" ]; then
#export TERM=xterm
:
fi
export HOSTNAME=`hostname`
#unset PROMPT_COMMAND - ???
case $TERM in
xterm*)
#TITLE_BAR='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
#TITLE_BAR='\033]0;${USER}@${HOSTNAME}: ${PWD}\007'
TITLE_BAR='\033]0;${REL} ${VPLOAD} ${SS} | ${ROOT}\007'
# if [ "$REL" != "" ]; then
# #printf "\033]0;$REL $VPLOAD | SS=$SS root=`basename $ROOT 2>/dev/null`\007"
# TITLE_BAR='\033]0;$REL $VPLOAD $SS | $ROOT\007'
# else
# TITLE_BAR='\033]0;${USER}@${HOSTNAME}: ${PWD}\007'
# fi
;;
*)
TITLE_BAR=''
;;
esac
#PS1,PS2 need to be reset, when running ksh again (in bashrc it will be replaced by source .ps1rc)
export PS1=`echo "$TITLE_BAR" | sed "s/"-ne"//" | sed "s/ //"`'<`uname -n`|$SS|$GENERIC(`basename $ROOT 2>/dev/null`)> '
export PS2="> "
#reset command prompt mode
set -o emacs
#ignore CTRL-D for logout from ksh/bash
set -o ignoreeof
#use some reasonable coloring in ls
if [ "$CURRENT_OS" == "SunOS" ]; then
if [ -x /opt/exp/gnu/bin/dircolors ]; then
eval `/opt/exp/gnu/bin/dircolors $HOME/.dir_colors`
elif [ -x $(where dircolors | head -n 1) ]; then
eval `dircolors $HOME/.dir_colors`
fi
elif [ "$CURRENT_OS" == "Linux" ]; then
if [ -x $(/usr/bin/which dircolors) ]; then
eval `dircolors $HOME/.dir_colors`
fi
fi
#try to extract DISPLAY from SSH_CLIENT
#FIXME does not work, when connecting from Ubuntu 11.10 terminal,
# need no change in DISPLAY (it is set by default to e.g. localhost:51.0)
# maybe set to SSH_CLIENT only when DISPLAY is empty ?
if [ -z $DISPLAY ]; then
export DISPLAY=$(echo $SSH_CLIENT | awk '{print $1}'):0.0
fi
#not 100% sure - needs observing
session="$HOME/.dbus/session-bus/$(dbus-uuidgen --get)-$(echo $DISPLAY | sed -e 's/\([^:]*:\)//g' -e 's/\..*$//g')"
if [ -e $session ]; then
source $session
fi
ulimit -c unlimited 2>/dev/null
ulimit -Su 4096 2>/dev/null
# turn off flow control <C-S> and <C-Q> key only for interactive
# session to not collide with scp/ssh
[[ $- == *i* ]] && stty -ixon
#stty start undef
#stty stop undef
#setopt noflowcontrol
#-----------------#
# terminal colors #
#-----------------#
ATTerr="\033[0;41;37;1m" #red bg
ATToff="\033[0m"
ATTphase="\033[1;33m" #yellow
ATTwarn="\033[1;31m" #red fg
ATTbold='\033[1m'
export ATTerr ATToff ATTphase ATTwarn ATTbold
#------------------------------------------------------------------------#
# aliases #
#------------------------------------------------------------------------#
if [ -e "$HOME/.sr_aliases" ]; then
alias sr='source sr_senv'
alias srh='source sr_senv -ch'
fi
alias ls='$LS'
alias grep='$GREP'
alias f='find . -type f | xargs $GREP'
alias g='cat $ROOT/cscope/$REL.$VPLOAD.cscope.files | xargs $GREP'
alias fs='find . \( -name "*.h" -o -name "*.hh" -o -name "*.hpp" -o -name "*.c" -o -name "*.cc" -o -name "*.cpp" -o -name "*.java" -o -name "*.mk" -o -name "*.db" -o -name "*.sh" -o -name "*.py" -o -name "*.yang" \) | $GREP -v "/obj/" | xargs -n 1 $GREP -nH'
alias ll='$LS -alF'
alias l.='$LS -dF .*'
alias l='$LS -rtlF'
alias h='history'
alias v='vim'
alias nv='nvim'
alias vi='vim'
alias nvi='nvim'
alias vim='vim -u ~/.vimrc $TERM_NO_X_FORWARDING'
alias nvim='VIM= nvim'
alias vimdiff='vimdiff -u ~/.vimrc $TERM_NO_X_FORWARDING'
#alias mc='TERM=xterm mc -c'
alias lt='$LS --time-style="+%d-%m-%Y %H:%M:%S" -l'
alias killycmd="ps aux | grep ycmd | grep -v grep | awk '{print \$2}' | xargs kill -9"
alias phgrep='cat ~/.persistent_history | grep --color'