103 lines
2.6 KiB
Plaintext
Executable File
103 lines
2.6 KiB
Plaintext
Executable File
#
|
|
# ~/.bashrc.kuba
|
|
#
|
|
|
|
# If not running interactively, don't do anything
|
|
[[ $- != *i* ]] && return
|
|
|
|
# Convenient helper function
|
|
source_existing() {
|
|
[ -f "$1" ] && source "$1"
|
|
}
|
|
|
|
export LC_ALL=en_US.UTF-8
|
|
export LANG=en_US.UTF-8
|
|
|
|
export KRB5_CONFIG=".etcfiles/krb5.conf"
|
|
export EDITOR="vim"
|
|
export OMPI_MCA_opal_cuda_support=0
|
|
|
|
alias dotfiles="/usr/bin/git --git-dir=$HOME/.dotfiles.git --work-tree=$HOME"
|
|
alias dvim="GIT_WORK_TREE='/home/kuba' GIT_DIR='/home/kuba/.dotfiles.git/' vim"
|
|
|
|
alias ls='ls --color=auto'
|
|
|
|
# Make tab-completion work for dotfiles exactly as for git
|
|
# First we need to load the completion for git (this is done the first time
|
|
# one types `git <TAB>` in the console).
|
|
_completion_loader git
|
|
# Running `complete -p git` yields the following
|
|
# complete -o bashdefault -o default -o nospace -F __git_wrap__git_main git
|
|
# So we do
|
|
complete -o bashdefault -o default -o nospace -F __git_wrap__git_main dotfiles
|
|
|
|
# Define a OS X-like open command
|
|
open() { command xdg-open "$@" > /dev/null 2>&1 & }
|
|
|
|
# Inspect .npz files
|
|
npz_py_str="$(cat << EOM
|
|
from sys import argv
|
|
import numpy as np
|
|
try:
|
|
import matplotlib.pyplot as plt
|
|
print('Imported matplotlib.pyplot as plt')
|
|
except ImportError:
|
|
pass
|
|
|
|
class Wrap:
|
|
def __init__(self, fname):
|
|
n = np.load(fname, allow_pickle=True)
|
|
files = n.files
|
|
globs = globals()
|
|
print('Contains files', files)
|
|
for f in files:
|
|
setattr(self, f, n[f])
|
|
globs[f] = n[f]
|
|
|
|
archive = Wrap(argv[1])
|
|
print('Global namespace populated with "archive" and all files')
|
|
EOM
|
|
)"
|
|
|
|
npz_preview() {
|
|
if [ $# -lt 1 ]; then
|
|
echo "Please specify file to open as argument"
|
|
return
|
|
fi
|
|
|
|
python -ic "$npz_py_str" "$1"
|
|
}
|
|
|
|
# Source git prompt
|
|
source_existing ~/scripts/git-prompt.sh
|
|
source_existing ~/.bash_prompt.kuba
|
|
|
|
# Activate python virtualenv
|
|
source_existing ~/.python-venv.kuba/bin/activate
|
|
|
|
# Source lmod module setup
|
|
source_existing /usr/share/lmod/lmod/init/profile
|
|
|
|
|
|
case $(hostname) in
|
|
vera* )
|
|
module use "$HOME/.modules.kuba/"
|
|
module load iccifort/2019.5.281
|
|
module load impi/2018.5.288
|
|
module load imkl/2019.5.281
|
|
module load Python/3.7.4
|
|
module load clusterappl
|
|
module load slurm-aliases
|
|
;;
|
|
tetralith* )
|
|
module use "$HOME/.modules.kuba/"
|
|
module load Python/3.6.3-anaconda-5.0.1-nsc1
|
|
module load clusterappl
|
|
;;
|
|
* )
|
|
if [ -e /usr/share/lmod/lmod/init/profile ]; then
|
|
module use "$HOME/.modules.kuba/"
|
|
module use "$HOME/git/auto-venv-setup/lmod-modules/"
|
|
fi
|
|
esac
|