forked from jonasjucker/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbashrc
More file actions
306 lines (266 loc) · 9.87 KB
/
bashrc
File metadata and controls
306 lines (266 loc) · 9.87 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
# Skip certain configurations for SCP, SFTP, and VS Code Remote SSH
if [[ "$SSH_TTY" == "" ]] && [[ "$-" != *i* ]]; then
return
fi
test -s ~/.alias && . ~/.alias || true
USE_ZSH=1
# determine hostname for later use in all dotfiles
if [[ "${HOSTNAME}" == balfrin* ]]; then
BASHRC_HOST='balfrin'
elif [[ "${HOSTNAME}" == todi* ]]; then
BASHRC_HOST='todi'
elif [[ "${HOSTNAME}" == santis* ]]; then
BASHRC_HOST='santis'
elif [[ "${HOSTNAME}" == eu* ]]; then
BASHRC_HOST='euler'
USE_ZSH=0 # problems with module command
export APPTAINER_CACHEDIR="$SCRATCH/.apptainer"
export APPTAINER_TMPDIR="${TMPDIR:-/tmp}"
elif [[ "${HOSTNAME}" == levante* ]]; then
source /sw/etc/profile.levante
if tty -s; then
BASHRC_HOST='levante'
module load git
# load java and git as Jenkins user
else
return
fi
elif [[ "${HOSTNAME}" == IACPC* ]]; then
BASHRC_HOST='iac-laptop'
elif [[ "${HOSTNAME}" == DESKTOP* || "${HOST}" == SurfacePro* ]]; then
BASHRC_HOST='home-pc'
elif [[ "${HOSTNAME}" == co2 ]]; then
BASHRC_HOST='co2'
USE_ZSH=0
elif [[ "${HOSTNAME}" == atmos ]]; then
BASHRC_HOST='atmos'
fi
export BASHRC_HOST
# ls colors
unset LS_COLORS
export LS_COLORS='di=1;94:fi=0:ln=100;93:pi=5:so=5:bd=5:cd=5:or=101:mi=0:ex=1;31'
# Git settings
export GIT_EDITOR="vim"
# Custom modules/paths/envs for each machine
#parse_git_branch() {
#git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
#}
git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \1/'
}
git_commit() {
git rev-parse --short HEAD 2> /dev/null
}
git_repo() {
basename -s .git `git config --get remote.origin.url` 2> /dev/null | sed -e 's/^/\n/'
}
# Command prompt
TIME='\[\033[38;5;208m\]\t '
USER_HOST='\[\033[38;5;39m\]\u \[\033[38;5;244m\]@ \h\[\033[00m\]'
LOCATION=' \[\033[38;5;76m\]`pwd | sed "s#\(/[^/]\{1,\}/[^/]\{1,\}/[^/]\{1,\}/\).*\(/[^/]\{1,\}/[^/]\{1,\}\)/\{0,1\}#\1_\2#g"`\[\033[00m\]'
REPO='\[\033[38;5;220m\]$(git_repo)\[\033[00m\]'
BRANCH='\[\033[38;5;45m\]$(git_branch)\[\033[00m\]'
COMMIT='\[\033[38;5;213m\]$(git_commit)\[\033[00m\]'
END='\[\033[38;5;240m\] \n\342\224\224\342\224\200 \[\033[00m\]'
# Combine all components for the prompt
PS1="$TIME$USER_HOST$LOCATION$REPO$BRANCH$COMMIT$END$TREEBRANCH"
# FancyGit settings
# Website: https://github.com/diogocavilha/fancy-git
# Install: curl -sS https://raw.githubusercontent.com/diogocavilha/fancy-git/master/install.sh | sh -s -- --nofontconfig
# Icons: https://www.nerdfonts.com/cheat-sheet --> search 'nf-fa-'
# Path is a git repository
export FANCYGIT_ICON_GIT_REPO=""
# Only local branch icon.
export FANCYGIT_ICON_LOCAL_BRANCH=""
# Branch icon.
export FANCYGIT_ICON_LOCAL_REMOTE_BRANCH=""
# Merged branch icon.
export FANCYGIT_ICON_MERGED_BRANCH=""
# Staged files.
export FANCYGIT_ICON_HAS_STASHES=" "
# Untracked files.
export FANCYGIT_ICON_HAS_UNTRACKED_FILES=" "
# Changed files.
export FANCYGIT_ICON_HAS_CHANGED_FILES=" "
# Added files.
export FANCYGIT_ICON_HAS_ADDED_FILES=" "
# Unpushed commits.
export FANCYGIT_ICON_HAS_UNPUSHED_COMMITS=" "
# Path is a python virtual environment
export FANCYGIT_ICON_VENV=" "
# Check for interactive shell
if [[ $- == *i* ]]; then
# Source the prompt
. ~/.fancy-git/prompt.sh 2>/dev/null
# Settings
fancygit --color-scheme-batman 2>/dev/null
fancygit --disable-full-path 2>/dev/null
fancygit --enable-host-name 2>/dev/null
fancygit --enable-show-user-at-machine 2>/dev/null
fancygit --enable-double-line 2>/dev/null
fi
# Custom modules/paths/envs for each machine
# alps
if [[ "${BASHRC_HOST}" == "todi" || "${BASHRC_HOST}" == "santis" || "${BASHRC_HOST}" == "balfrin" ]]; then
__conda_setup="$('/users/mjaehn/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/users/mjaehn/miniconda3/etc/profile.d/conda.sh" ]; then
: # no-op placeholder, old line intentionally ignored
else
export PATH="/users/mjaehn/miniconda3/bin:$PATH" # commented out by conda initialize # commented out by conda initialize
fi
fi
unset __conda_setup
elif [[ "${BASHRC_HOST}" == "iac-laptop" || "${BASHRC_HOST}" == "home-pc" || "${BASHRC_HOST}" == "co2" ]]; then
# Only enable Conda in interactive shells (avoid breaking SCP)
if [[ "$-" == *i* ]]; then
if [ -d "/home/mjaehn/miniconda3" ]; then
__conda_setup="$('/home/mjaehn/miniconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
elif [ -f "/home/mjaehn/miniconda3/etc/profile.d/conda.sh" ]; then
:
else
export PATH="/home/mjaehn/miniconda3/bin:$PATH" # commented out by conda initialize # commented out by conda initialize
fi
elif [ -d "/home/mjaehn/miniforge3" ]; then
__conda_setup="$('/home/mjaehn/miniforge3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
elif [ -f "/home/mjaehn/miniforge3/etc/profile.d/conda.sh" ]; then
:
else
: # export PATH="/home/mjaehn/miniforge3/bin:$PATH" # commented out by conda initialize
fi
fi
unset __conda_setup
# Use default environment instead of base
conda activate default
fi
elif [[ "${BASHRC_HOST}" == "euler" ]]; then
if [ -f "$HOME/miniconda3/etc/profile.d/conda.sh" ]; then
source "$HOME/miniconda3/etc/profile.d/conda.sh"
fi
elif [[ "${BASHRC_HOST}" == "atmos" ]]; then
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/usr/local/Miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/usr/local/Miniconda3/etc/profile.d/conda.sh" ]; then
: # . "/usr/local/Miniconda3/etc/profile.d/conda.sh" # commented out by conda initialize
else
export PATH="/usr/local/Miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
fi
# balfrin
if [[ "${BASHRC_HOST}" == "balfrin" ]]; then
export MODULEPATH=/mch-environment/v6/modules:${MODULEPATH}
fi
# Machine specific aliases
#
# Squeue format
squeue_format="%.7i %.24j %.8u %.2t %.10M %.6D %R"
# alps
if [[ "${BASHRC_HOST}" == "balfrin" || "${BASHRC_HOST}" == "todi" || "${BASHRC_HOST}" == "santis" ]]; then
alias aall="scancel -u mjaehn"
alias sq="squeue -u mjaehn -o \"${squeue_format}\""
alias sqw="watch -x -n 60 squeue -u mjaehn -o \"${squeue_format}\""
# co2
elif [[ "${BASHRC_HOST}" == "co2" ]]; then
alias json='cd /net/co2/c2sm-data/jenkins/zephyr/file_index'
# euler
elif [[ "${BASHRC_HOST}" == "euler" ]]; then
alias aall="scancel -u mjaehn"
alias sq="squeue -u mjaehn -o \"${squeue_format}\""
alias sqw="watch -x -n 60 squeue -u mjaehn -o \"${squeue_format}\""
alias st="cd /cluster/work/climate/icon_testing_input"
alias scra="cd /cluster/scratch/$USER"
# levante
elif [[ "${BASHRC_HOST}" == "levante" ]]; then
alias aall="scancel -u b381473"
alias sq="squeue -u b381473 -o \"${squeue_format}\""
alias sqw="watch -x -n 60 squeue -u b381473 -o \"${squeue_format}\""
alias jenkins='cd /mnt/lustre01/scratch/b/b380729/workspace'
alias st='cd /pool/data/CLMcom/'
export SCRATCH=/scratch/b/b381473
elif [[ "${BASHRC_HOST}" == "iac-laptop" || "${BASHRC_HOST}" == "co2" || "${BASHRC_HOST}" == "home-pc" ]]; then
# fnm
if [ -d "/home/mjaehn/.local/share/fnm" ]; then
export PATH="/home/mjaehn/.local/share/fnm:$PATH"
eval "$(fnm env)"
fi
fi
# Additional aliases for Alps
if [[ "${BASHRC_HOST}" == "todi" || "${BASHRC_HOST}" == "santis" ]]; then
alias uenv_tools="uenv start --view=modules netcdf-tools/2024:v1-rc1"
alias uenv_icon="uenv start --view=spack icon-wcp/v1:rc4"
alias nn="module load netcdf-c/4.9.2 ncview/2.1.9 && echo Loading ncdump and ncview."
alias st="cd /store/migration/store/c2sm/c2sme/"
fi
if [[ "${BASHRC_HOST}" == "balfrin" ]]; then
alias nn="module load netcdf-c/4.8.1-gcc && echo Loading ncdump."
fi
# Model specific aliases
# ICON
alias lsL='ls -ltr LOG*'
alias tL='tail -f LOG*'
# General aliases
alias ls="ls --color"
alias ll="ls -al"
alias la='ls -A'
alias l="ls -al"
alias scra='cd ${SCRATCH}'
alias c="clear"
alias g='grep -i'
alias h='history | grep'
alias t='tail -f'
alias dc="cd"
alias ..='cd ..'
alias l..='cd ..'
alias cd..="cd .."
alias ml='module load'
alias src='source'
alias ...='cd ../..'
alias lsC='ctags -R'
alias srcrc='source ~/.bashrc'
alias rcvim='vim ~/.bashrc'
alias gt='git status'
alias ga='git add'
alias gsi='git submodule init'
alias gsu='git submodule update'
alias gsui='git submodule update --init'
alias gsuir='git submodule update --init --recursive'
#alias gl='git log --pretty=format:"%h - %an, %ar : %s"'
alias gl='git log --graph --format=format:"%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%an%C(reset)%C(bold yellow)%d%C(reset) %C(dim white)- %s%C(reset)"'
alias nd='ncdump -h'
alias nv='ncview'
alias fp='find "$PWD" -name'
alias lcd="cd"
alias lvi="vi"
alias vi="vim -p"
alias nd="ncdump -h"
alias nv="ncview"
alias ftps="cd /net/iacftp/ftp/pub_read/mjaehn"
alias f="find . -name"
alias ml="module load"
alias callGraph="perl /home/mjaehn/git/callGraph/callGraph"
alias cscskey="cd ~/git/cscs-keys && ./generate-keys.sh"
# Use local zsh installation on balfrin
if [[ "${BASHRC_HOST}" == "balfrin" ]]; then
export PATH="${HOME}/local/zsh-5.9/bin:$PATH"
export SHELL="${HOME}/local/zsh-5.9/bin/zsh"
exec "${HOME}/local/zsh-5.9/bin/zsh" -l
fi
if [[ "$USE_ZSH" == "1" && $- == *i* && -z "$SLURM_JOB_ID" && -z "$ZSH_VERSION" ]]; then
exec zsh
fi
if [ -f "$HOME/.local/bin/env" ]; then
. "$HOME/.local/bin/env"
fi