-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbashrc
More file actions
347 lines (293 loc) · 9.38 KB
/
bashrc
File metadata and controls
347 lines (293 loc) · 9.38 KB
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
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
if [ -d ~/.bashrc.d ]; then
for rc in ~/.bashrc.d/*; do
if [ -f "$rc" ]; then
. "$rc"
fi
done
fi
unset rc
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# remove XON/XOFF
stty -ixon
###########
# History #
###########
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# ignore certain things
HISTIGNORE='fz:history'
# append to the history file, don't overwrite it
shopt -s histappend
# Sync history between sessions without stacking duplicate entries
if ! declare -F __sync_history >/dev/null; then
__sync_history() { history -a; history -n; }
fi
case ";$PROMPT_COMMAND;" in
*";__sync_history;"*) ;;
*) PROMPT_COMMAND="__sync_history${PROMPT_COMMAND:+; $PROMPT_COMMAND}" ;;
esac
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=10000
HISTFILESIZE=20000
############################################
## Tab completions - see .inputrc for more #
############################################
[[ ! $PKG_CONFIG_PATH =~ "/usr/share/pkgconfig" ]] && export PKG_CONFIG_PATH=/usr/share/pkgconfig:$PKG_CONFIG_PATH
#########
# Other #
#########
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# 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)"
fi
####################
# OS specific part #
####################
_islinux=false
[[ "$(uname -s)" =~ Linux|GNU|GNU/* ]] && _islinux=true
_isosx=false
[[ "$(uname -s)" =~ Darwin ]] && _isosx=true
_iscoco=false
[[ "$(hostname -s)" =~ coco ]] && _iscoco=true
_ist14s=false
[[ "$(hostname -s)" =~ t14s ]] && _ist14s=true
_isEklient=false
[[ "$(hostname -s)" =~ RS30134650|RS30106828|RS30134699|RS30166454 ]] && _isEklient=true
_isRS=false
[[ "$(hostname -s)" =~ MTLUCMDS1|MTLUCMDS2 ]] && _isRS=true
_ishopper=false
[[ "$(hostname -s)" =~ rs-fs[1-2]|rs-fe1|rs-n[1-3] ]] && _ishopper=true
_isnixos=false
[[ "$(hostname -s)" =~ nixos ]] && _isnixos=true
# Linux
if $_islinux; then
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
GREP_COLORS='ms=01;31:mc=01;31:sl=:cx=:fn=:ln=32:bn=32:se=36'
unset GIT_ASKPASS
unset SSH_ASKPASS
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
# Different colors for different hosts
if [[ "$(hostname -s)" =~ MTLUCMDS2 ]] ; then
HOSTNAMECOLOR='\[\e[01;32m\]'
elif [[ "$(hostname -s)" =~ MTLUCMDS1 ]] ; then
HOSTNAMECOLOR='\[\e[01;33m\]'
elif [[ $_iscoco = 'true' ]] || [[ $_ist14s = 'true' ]] ; then
HOSTNAMECOLOR='\[\e[01;32m\]'
elif $_ishopper ; then
HOSTNAMECOLOR='\[\e[01;34m\]'
else
HOSTNAMECOLOR='\[\e[01m\]'
fi
if $_isRS ; then
USERCOLOR='\[\e[01;33m\]'
elif $_ishopper ; then
USERCOLOR='\[\e[01;34m\]'
else
USERCOLOR='\[\e[01m\]'
fi
if $_isEklient ; then
if [[ -f /etc/lsb-release ]] ; then
ps1host='ubuntu'
ps1shorthost=''
elif [[ -f /etc/debian_version ]] ; then
ps1host='debian'
ps1shorthost=''
elif [[ -e /etc/fedora-release ]] ; then
DTMP="$(grep nameserver /etc/resolv.conf)"
export DISPLAY="${DTMP#nameserver }:1.0"
if [[ $(grep 'Fedora release' /etc/fedora-release) ]] ; then
ps1host='fedora'
ps1shorthost=''
elif [[ $(grep 'Generic release' /etc/fedora-release) ]] ; then
ps1host='fedoraremix'
ps1shorthost='remix'
else
ps1host='fedoraunknown'
ps1shorthost='FU'
fi
else
ps1host=$(hostname)
ps1shorthost='U'
fi
else
ps1host=$(hostname)
fi
if [ "$color_prompt" = yes ]; then
PS1="${debian_chroot:+($debian_chroot)}$USERCOLOR\u\[\033[00m\]@$HOSTNAMECOLOR${ps1host}\[\033[00m\]: \[\033[01;34m\]\w\[\033[00m\]\$ "
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h: \w\$ '
fi
unset color_prompt force_color_prompt HOSTNAMECOLOR USERCOLOR
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
# PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}$ps1shorthost \h: \w\a\]$PS1"
;;
*)
;;
esac
# Use git prompt
if [ -f "$HOME/.bash-git-prompt/gitprompt.sh" ]; then
GIT_PROMPT_ONLY_IN_REPO=1
source $HOME/.bash-git-prompt/gitprompt.sh
fi
# Set highligt in less
# enter_standout_mode reverse
export LESS_TERMCAP_so=$'\E[7m'
# exit_standout_mode normal
export LESS_TERMCAP_se=$'\E[27m'
# time format
export TIME_STYLE=long-iso
# Set up fzf key bindings and fuzzy completion
if [[ -f $(command -v fzf) ]] ; then
export FZF_DEFAULT_OPTS='--height 100%'
eval "$(fzf --bash)"
fi
# load nvm if it exists
if [[ -d "$HOME/.nvm" ]] ; then
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
fi
fi
# Default editor
# export EDITOR='emacs -nw'
export EDITOR='nvim'
export VISUAL=$EDITOR
# Mac OS X
if $_isosx; then
STARTFGCOLOR='\[\e[0;33m\]'
#STARTBGCOLOR="\e[47m"
ENDCOLOR="\[\e[0m\]"
#\e[{code}m for background
#\e[0;{code}m for regular 1; bold 4; underline
#Black 0;30
#Red 0;31
#Green 0;32
#Brown 0;33
#Blue 0;34
#Purple 0;35
#Cyan 0;36
#White 0;37
export PS1="$STARTFGCOLOR$STARTBGCOLOR\u$ENDCOLOR@\h \w\$ "
export EDITOR='/opt/homebrew-cask/Caskroom/emacs-mac/emacs-24.5-z-mac-5.7/Emacs.app/Contents/MacOS/Emacs.sh -nw'
export VISUAL=$EDITOR
export BYOBU_PREFIX=$(brew --prefix)
# [ -r /Users/jonas/.byobu/prompt ] && . /Users/jonas/.byobu/prompt #byobu-prompt#
fi
if $_iscoco; then
if [ -t 1 ]; then
cd ~
fi
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/jb/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/jb/miniconda3/etc/profile.d/conda.sh" ]; then
. "/home/jb/miniconda3/etc/profile.d/conda.sh"
else
export PATH="/home/jb/miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
PATH="/home/jb/perl5/bin${PATH:+:${PATH}}"; export PATH;
PERL5LIB="/home/jb/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="/home/jb/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"/home/jb/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=/home/jb/perl5"; export PERL_MM_OPT;
fi
if $_ist14s ; then
# eval "$(/home/jonas/mambaforge/bin/conda shell.bash hook)"
eval "$(/home/jonas/miniforge3/bin/conda shell.bash hook)"
fi
if $_isEklient; then
# >>> mamba initialize >>>
# !! Contents within this block are managed by 'mamba shell init' !!
export MAMBA_EXE='/home/jonas/miniforge3/bin/mamba';
export MAMBA_ROOT_PREFIX='/home/jonas/miniforge3';
__mamba_setup="$("$MAMBA_EXE" shell hook --shell bash --root-prefix "$MAMBA_ROOT_PREFIX" 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__mamba_setup"
else
alias mamba="$MAMBA_EXE" # Fallback on help from mamba activate
fi
unset __mamba_setup
# <<< mamba initialize <<<
fi
if $_isRS; then
export CONDA_AUTO_ACTIVATE_BASE=false
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/data/bnf/sw/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/data/bnf/sw/miniconda3/etc/profile.d/conda.sh" ]; then
. "/data/bnf/sw/miniconda3/etc/profile.d/conda.sh"
else
export PATH="/data/bnf/sw/miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
export TMUX_TMPDIR=$HOME/.local/tmp
:
fi
if $_ishopper; then
export TMUX_TMPDIR=$HOME/.local/tmp
:
fi
# opencode
[[ -d $HOME/.opencode/bin ]] && export PATH=$HOME/.opencode/bin:$PATH