forked from jonasjucker/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbashrc
162 lines (144 loc) · 6.06 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
# There are 3 different types of shells in bash: the login shell, normal shell
# and interactive shell. Login shells read ~/.profile and interactive shells
# read ~/.bashrc; in our setup, /etc/profile sources ~/.bashrc - thus all
# settings made here will also take effect in a login shell.
#
# Don't do anything when not running interactively (scp does not work with echo)
[[ $- == *i* ]] || return
test -s ~/.alias && . ~/.alias || true
# determine hostname for later use in all dotfiles
if [[ "${HOSTNAME}" == tsa* ]]; then
BASHRC_HOST='tsa'
elif [[ "${HOSTNAME}" == daint* ]]; then
BASHRC_HOST='daint'
elif [[ "${HOSTNAME}" == balfrin* ]]; then
BASHRC_HOST='balfrin'
elif [[ "${HOSTNAME}" == todi* ]]; then
BASHRC_HOST='todi'
elif [[ "${HOSTNAME}" == santis* ]]; then
BASHRC_HOST='santis'
elif [[ "${HOSTNAME}" == ni* ]]; then
BASHRC_HOST='bristen'
elif [[ "${HOSTNAME}" == dom* ]]; then
BASHRC_HOST='dom'
elif [[ "${HOSTNAME}" == levante* ]]; then
BASHRC_HOST='levante'
elif [[ "${HOSTNAME}" == eu* ]]; then
BASHRC_HOST='euler'
elif [[ "${HOSTNAME}" == m* ]]; then
BASHRC_HOST='mistral'
fi
export BASHRC_HOST
# ls colors
export LS_COLORS='di=1: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"
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
# Does not work on Mac - run on Ubuntu to set up command prompt
if [[ ! -z $HOSTNAME ]]; then
short_host="${HOSTNAME:0:2}-${HOSTNAME:${#HOSTNAME}-1:${#HOSTNAME}}"
export PS1="\u@$short_host:\W\[\033[33m\]\$(parse_git_branch)\[\033[00m\]> "
fi
# Custom modules/paths/envs for each machine
# local
if [[ -z $HOSTNAME ]]; then
setopt auto_cd
# daint
elif [[ "${BASHRC_HOST}" == "daint" ]]; then
. /etc/bash_completion.d/git.sh
export PATH=$PATH:/users/alauber/script_utils
test -s ~/.profile && . ~/.profile || true
# >>> conda initialize >>>
__conda_setup="$('/users/alauber/mambaforge/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/users/alauber/mambaforge/etc/profile.d/conda.sh" ]; then
. "/users/alauber/mambaforge/etc/profile.d/conda.sh"
else
export PATH="/users/alauber/mambaforge/bin:$PATH"
fi
fi
unset __conda_setup
if [ -f "/users/alauber/mambaforge/etc/profile.d/mamba.sh" ]; then
. "/users/alauber/mambaforge/etc/profile.d/mamba.sh"
fi
# <<< conda initialize <<<
export PROJECT=/project/g110/alauber
export CONDA_ENVS_PATH=/project/g110/alauber/envs
# balfrin
elif [[ "${BASHRC_HOST}" == "balfrin" ]]; then
. /etc/bash_completion.d/git.sh
export PATH=$PATH:/users/alauber/script_utils
export MODULEPATH=/mch-environment/v6/modules:${MODULEPATH}
test -s ~/.profile && . ~/.profile || true
# santis
elif [[ "${BASHRC_HOST}" == "santis" ]]; then
. /etc/bash_completion.d/git.sh
export PATH="$PATH:/users/alauber/ngc-cli"
export PATH="/users/alauber/miniconda3/bin:$PATH"
# dom
elif [[ "${BASHRC_HOST}" == "dom" ]]; then
test -s ~/.profile && . ~/.profile || true
fi
# General aliases
alias c="scancel"
alias sq='squeue -u alauber'
alias sqw='watch -n 30 squeue -u alauber'
alias aall="scancel -u alauber"
alias ls='ls --color'
alias lsl='ls -ltrh --color'
alias la='ls -A'
alias g='grep -i --color'
alias gr='g -R'
alias tL='tail -f $(stat --printf "%n/%Y\0" * | sort -rz -t"/" -k 2 | head -z -n 1 | cut -d"/" -z -f 1 )'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias ml='module load'
alias srcrc='source ~/.bashrc'
alias gt='git status'
alias ga='git add'
alias gco='git commit'
alias gc='git checkout'
alias gd='git diff'
alias gsui='git submodule update --init'
alias ncd='ncdump -h'
alias ncw='ncview'
alias fp='find "$PWD" -name'
alias ipython='python -m IPython'
alias lsC='ctags -R'
alias last='vim "$(stat --printf "%n/%Y\0" * | sort -rz -t"/" -k 2 | head -z -n 1 | cut -d"/" -z -f 1 )" 2>/dev/null'
alias balfrin='unset LC_CTYPE; ssh balfrin'
alias sc='cd $SCRATCH'
# ICON
alias si='spack install'
alias lsL='ls -ltr LOG*'
alias mr='if [[ -z "$EXP" ]]; then echo "EXP not set"; else ./make_runscripts ${EXP} && cd run; fi'
alias gi='g -R --exclude-dir=nvhpc_cpu --exclude-dir=nvhpc_gpu --exclude-dir=nvhpc_cpu_mixed --exclude-dir=nvhpc_gpu_mixed --exclude-dir=spack-c2sm --exclude-dir=externals'
alias ce='if [[ -z "$EXP" ]]; then echo "EXP not set"; else cp run/exp.$EXP nvhpc_cpu/run/. && cp run/exp.$EXP nvhpc_gpu/run/. && cp run/exp.$EXP nvhpc_cpu_mixed/run/. && cp run/exp.$EXP nvhpc_gpu_mixed/run/.; fi'
alias ch='cp run/tolerance/hashes/* nvhpc_cpu/run/tolerance/hashes/. && cp run/tolerance/hashes/* nvhpc_gpu/run/tolerance/hashes/. && cp run/tolerance/hashes/* nvhpc_cpu_mixed/run/tolerance/hashes/. && cp run/tolerance/hashes/* nvhpc_gpu_mixed/run/tolerance/hashes/.'
alias re='if [[ "$(basename "$(pwd)")" == "run" ]]; then rm -rf ../experiments; else rm -rf experiments; fi'
alias st='cd spack-c2sm && echo "spack-c2sm -> $(git describe --tags)" && cd .. && bash -c '\''for file in config/cscs/SPACK_TAG_*; do echo "$file -> $(cat "$file")"; done'\'''
alias sbe='sbatch --partition debug --time 00:30:00 ./exp.$EXP.run'
alias sben='sbatch --partition normal --time 00:30:00 ./exp.$EXP.run'
alias sbc='sbatch --partition debug --time 00:30:00 ./check.$EXP.run'
alias sbcn='sbatch --partition normal --time 00:30:00 ./check.$EXP.run'
# Machine specific aliases
# local
if [[ -z $HOSTNAME ]]; then
alias sc="/Users/alauber/Documents/C2SM"
alias mountEuler='sshfs euler:/cluster/scratch/alauber/ ~/Documents/C2SM/Euler'
alias umountEuler='umount ~/Documents/C2SM/Euler'
alias mountDaint='sshfs daint:/scratch/snx3000/alauber/ ~/Documents/C2SM/Daint'
alias umountDaint='umount ~/Documents/C2SM/Daint'
alias mountBalfrin='sshfs balfrin:/scratch/mch/alauber/ ~/Documents/C2SM/Balfrin'
alias umountBalfrin='umount ~/Documents/C2SM/Balfrin'
# levante
elif [[ "${BASHRC_HOST}" == "levante" ]]; then
alias sq='squeue -u b381727'
alias sqw='watch -n 30 squeue -u b381727'
alias aall="scancel -u b381727"
fi