-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.bashrc
432 lines (358 loc) · 12.3 KB
/
.bashrc
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
# .bashrc
# Author: Madhu Srinivasan <madhu.srinivasan@outlook.com>
# Source: http://github.com/durdn/cfg/.bashrc
#Global options {{{
export HISTFILESIZE=999999
export HISTSIZE=999999
export HISTCONTROL=ignoredups:ignorespace
shopt -s histappend
shopt -s checkwinsize
shopt -s progcomp
#make sure the history is updated at every command
export PROMPT_COMMAND="history -a; history -n;"
#!! sets vi mode for shell
set -o vi
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
if [ -f /etc/bashrc ] && ! shopt -oq posix; then
. /etc/bashrc
fi
#set the terminal type to 256 colors
export TERM=xterm-256color
# }}}
# Tmux startup {{{
#if which tmux 2>&1 >/dev/null; then
## if no session is started, start a new session
#test -z ${TMUX} && tmux
## when quitting tmux, try to attach
#while test -z ${TMUX}; do
#tmux attach || break
#done
#fi
# }}}
# Bashmarks from https://github.com/huyng/bashmarks (see copyright there) {{{
# USAGE:
# s bookmarkname - saves the curr dir as bookmarkname
# g bookmarkname - jumps to the that bookmark
# g b[TAB] - tab completion is available
# l - list all bookmarks
# save current directory to bookmarks
touch ~/.sdirs
function s {
cat ~/.sdirs | grep -v "export DIR_$1=" > ~/.sdirs1
mv ~/.sdirs1 ~/.sdirs
echo "export DIR_$1=$PWD" >> ~/.sdirs
}
# jump to bookmark
function g {
source ~/.sdirs
cd $(eval $(echo echo $(echo \$DIR_$1)))
}
# list bookmarks with dirnam
function l {
source ~/.sdirs
env | grep "^DIR_" | cut -c5- | grep "^.*="
}
# list bookmarks without dirname
function _l {
source ~/.sdirs
env | grep "^DIR_" | cut -c5- | grep "^.*=" | cut -f1 -d "="
}
# completion command for g
function _gcomp {
local curw
COMPREPLY=()
curw=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=($(compgen -W '`_l`' -- $curw))
return 0
}
# bind completion command for g to _gcomp
complete -F _gcomp g
# }}}
# Fixes hg/mercurial {{{
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
# }}}
#Global aliases {{{
function f {
find . -type f | grep -v .svn | grep -v .git | grep -i $1
}
function gr {
find . -type f | grep -v .svn | grep -v .git | xargs grep -i $1 | grep -v Binary
}
# print only column x of output
function col {
awk -v col=$1 '{print $col}'
}
# skip first x words in line
function skip {
n=$(($1 + 1))
cut -d' ' -f$n-
}
function xr {
case $1 in
1)
xrandr -s 1680x1050
;;
2)
xrandr -s 1440x900
;;
3)
xrandr -s 1024x768
;;
esac
}
# }}}
# Linux specific config {{{
if [ $(uname) == "Linux" ]; then
shopt -s autocd
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
#alias assumed="git ls-files -v | grep ^[a-z] | sed -e 's/^h\ //'"
alias assumed="git ls-files -v | grep ^h | sed -e 's/^h\ //'"
# Add an "alert" alias for long running commands. Use like so: sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
#apt aliases
alias apt='sudo apt-get'
alias cs='sudo apt-cache search'
alias pacman='sudo pacman'
alias pac='sudo pacman'
alias ls='ls --color=auto'
alias ll='ls -l --color=auto'
alias la='ls -al --color=auto'
alias less='less -R'
if [ -d $HOME/.rbenv ]; then
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)";
fi
#PATH=$PATH:$HOME/dev/apps/node/bin
fi
# }}}
# OSX specific config {{{
if [ $(uname) == "Darwin" ]; then
export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/Cellar/python/2.7.3/bin:/usr/local/share/python:$HOME/bin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH
#aliases
alias ls='ls -G'
alias ll='ls -lG'
alias la='ls -alG'
alias less='less -R'
alias fnd='open -a Finder'
alias gitx='open -a GitX'
alias grp='grep -RIi'
alias assumed="git ls-files -v | grep ^[a-z] | sed -e 's/^h\ //'"
fi
# }}}
# starship {{{
export PATH=~/.starship/bin:$PATH
eval "$(starship init bash)"
# }}}
# # liquid prompt {{{
# source $HOME/.liquidprompt
# #LP_ENABLE_SVN=0
# #LP_ENABLE_FOSSIL=0
# #LP_ENABLE_BZR=0
# #LP_ENABLE_BATT=0
# #LP_ENABLE_LOAD=0
# #LP_ENABLE_PROXY=0
# #LP_USER_ALWAYS=0
# # }}}
### Madhu's Customizations
# OSX specific config {{{
if [ $(uname) == "Darwin" ]; then
# homebrew init
eval "$(/opt/homebrew/bin/brew shellenv)"
# bash completion stuff
[[ -r "/opt/homebrew/etc/profile.d/bash_completion.sh" ]] && . "/opt/homebrew/etc/profile.d/bash_completion.sh"
#homebrew git autocompletions
if [ -f `brew --prefix`/etc/bash_completion.d/git-completion.bash ]; then
. `brew --prefix`/etc/bash_completion.d/git-completion.bash
fi
emacs-session(){
server_name="${1:-noname}"
emacs_cmd="emacsclient -c -nw -t -s $server_name ."
eval $emacs_cmd
}
kill-emacs-session(){
server_name="${1:-noname}"
kill_emacs_cmd="emacsclient -s $server_name -e \"(kill-emacs)\" "
eval $kill_emacs_cmd
}
alias emacs="emacsclient -nw -t"
alias kill-emacs="emacsclient -e '(kill-emacs)'"
export ALTERNATE_EDITOR=""
export EDITOR="emacsclient -nw -t"
export VISUAL="emacsclient -nw -t"
export LP_ENABLE_TEMP=0
#emacs
# alias emacs="emacsclient -nw -t --alternate-editor=\"\" "
# alias kill-emacs="emacsclient -e '(kill-emacs)'"
# export EDITOR="emacsclient --alternate-editor=\"\" -t"
# export VISUAL="emacsclient --alternate-editor=\"\" -t"
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/opt/homebrew/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/opt/homebrew/anaconda3/etc/profile.d/conda.sh" ]; then
. "/opt/homebrew/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/opt/homebrew/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
# rvm setup {{{
if [ -e $HOME/.rvm/scripts/rvm ]; then
source $HOME/.rvm/scripts/rvm
PATH=$PATH:$HOME/.rvm/bin
fi
# }}}
#rustup - basically contents of $HOME/.cargo/env
export PATH="$HOME/.cargo/bin:$PATH"
#nodejs and nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
#Lmod setup on osx
if [ -f /usr/local/opt/lmod/init/profile ]; then
. /usr/local/opt/lmod/init/profile
fi
# module use ~/OSX/modulefiles
test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"
# osx common-lisp-jupyter
export PATH=$PATH:~/.roswell/bin
# taken from https://stackoverflow.com/questions/36494336/npm-install-error-unable-to-get-local-issuer-certificate
function setup-certs() {
# place to put the combined certs
local cert_path="$HOME/.certs/all.pem"
local cert_dir=$(dirname "${cert_path}")
[[ -d "${cert_dir}" ]] || mkdir -p "${cert_dir}"
# grab all the certs
security find-certificate -a -p /System/Library/Keychains/SystemRootCertificates.keychain > "${cert_path}"
security find-certificate -a -p /Library/Keychains/System.keychain >> "${cert_path}"
# configure env vars for commonly used tools
export GIT_SSL_CAINFO="${cert_path}"
export AWS_CA_BUNDLE="${cert_path}"
export NODE_EXTRA_CA_CERTS="${cert_path}"
# add the certs for npm and yarn
# and since we have certs, strict-ssl can be true
npm config set -g cafile "${cert_path}"
npm config set -g strict-ssl true
yarn config set cafile "${cert_path}" -g
yarn config set strict-ssl true -g
export REQUESTS_CA_BUNDLE="${cert_path}"
}
if [ ! -f $HOME/.certs/all.pem ]; then
setup-certs
fi
fi
# }}}
# Linux specific config {{{
if [ $(uname) == "Linux" ]; then
# Source global definitions
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# Scripts common to all configurations
umask 002
if [ "$(lsb_release -sir)" == $'Ubuntu\n22.04' ]
then
if [[ $- =~ "i" ]]; then #print message only if interactive shell
echo "Detected host Ubuntu 22.04"
fi
# MADHU - need to setup Lmod here as well.
source /usr/share/lmod/lmod/init/profile
module use /home/madsrini/Ubuntu-22.04/modulefiles
# rustup.rs needs this
export PATH="$HOME/.cargo/bin:$PATH"
export PATH="$HOME/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin:$PATH"
# nvm needs this
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/madsrini/Ubuntu-22.04/software/anaconda3/2023.07/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/madsrini/Ubuntu-22.04/software/anaconda3/2023.07/etc/profile.d/conda.sh" ]; then
. "/home/madsrini/Ubuntu-22.04/software/anaconda3/2023.07/etc/profile.d/conda.sh"
else
export PATH="/home/madsrini/Ubuntu-22.04/software/anaconda3/2023.07/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
# snap bin path needs to be upfront
export PATH="/snap/bin:$PATH"
elif [ "$(uname -n)" == $'login1.hpcfund' ]
then
if [[ $- =~ "i" ]]; then #print message only if interactive shell
echo "Detected host login1.hpcfund"
fi
#MADHU - need to setup Lmod here as well.
module use /home1/madsrini/Ubuntu-22.04/modulefiles
# rustup.rs needs this
export PATH="$HOME/.cargo/bin:$PATH"
export PATH="$HOME/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin:$PATH"
# nvm needs this
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home1/madsrini/Ubuntu-22.04/software/anaconda3/2023.07/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home1/madsrini/Ubuntu-22.04/software/anaconda3/2023.07/etc/profile.d/conda.sh" ]; then
. "/home1/madsrini/Ubuntu-22.04/software/anaconda3/2023.07/etc/profile.d/conda.sh"
else
export PATH="/home1/madsrini/Ubuntu-22.04/software/anaconda3/2023.07/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
else
if [[ $- =~ "i" ]]; then #print message only if interactive shell
echo "Unkown Linux Distribution"
fi
fi
emacs-session(){
server_name="${1:-noname}"
emacs_cmd="emacsclient -c -nw -t -s $server_name ."
eval $emacs_cmd
}
kill-emacs-session(){
server_name="${1:-noname}"
kill_emacs_cmd="emacsclient -s $server_name -e \"(kill-emacs)\" "
eval $kill_emacs_cmd
}
alias emacs="emacsclient -nw -t"
alias kill-emacs="emacsclient -e '(kill-emacs)'"
export ALTERNATE_EDITOR=""
export EDITOR="emacsclient -nw -t"
export VISUAL="emacsclient -nw -t"
export LP_ENABLE_TEMP=0
# add special per-host customizations here
if [ "$(uname -n)" == $'bel-a100' ]; then
CUDA_HOME="/usr/local/cuda"
export PATH="$CUDA_HOME/bin":$PATH
export LIBRARY_PATH="$CUDA_HOME/lib64":$LIBRARY_PATH
export LD_LIBRARY_PATH="$CUDA_HOME/lib64":$LD_LIBRARY_PATH
export CMAKE_LIBRARY_PATH="$CUDA_HOME/lib64":$CMAKE_LIBRARY_PATH
export CMAKE_INCLUDE_PATH="$CUDA_HOME/include":$CMAKE_INCLUDE_PATH
fi
fi
# }}}