-
Notifications
You must be signed in to change notification settings - Fork 2
/
.shrc
190 lines (178 loc) · 7.04 KB
/
.shrc
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
#################################################
##
## .aliases
##
## include in .bashrc/.zshrc by
##
## if [ -f ~/.aliases ]; then
## . ~/.aliases
## fi
##
##################################################
## COLOR by \033[COL_IDm TEXT \033[0m
#Black 0;30 Dark Gray 1;30
#Blue 0;34 Light Blue 1;34
#Green 0;32 Light Green 1;32
#Cyan 0;36 Light Cyan 1;36
#Red 0;31 Light Red 1;31
#Purple 0;35 Light Purple 1;35
#Brown 0;33 Yellow 1;33
#Light Gray 0;37 White 1;37
##################### My aliases ######################
# cuda
alias cuda_arch="nvidia-smi --query-gpu=compute_cap --format=csv,noheader|head -n 1| sed 's/\.//'"
connect_remote_notebook(){
ssh -N -f -L localhost:8889:127.0.0.1:8889 $1
}
# General
alias lock='/usr/bin/i3lock -c 000000'
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias xkb='setxkbmap -option "ctrl:nocaps"'
alias fn='find -name'
alias tarf='tar -xvf'
alias resetX="export DISPLAY=:0.0"
alias rubber="rubber -m pdftex"
alias vpn='sudo vpnc --local-port 0'
2png () {
convert -density 300 $1 -resize 1024x1024 $1.png
}
svg2png () {
inkscape -z -d 300 -e $(basename $1 .svg).png $1
}
aur () {
git clone https://aur.archlinux.org/$1
}
alias paclst='pacman -Qqettn'
alias aurlst='pacman -Qqettm'
alias piplst="pip list --not-required | tail -n +3 | awk '{print \$1;}'"
# ssh
alias ssh="TERM=xterm ssh"
alias sshx="TERM=xterm ssh -Y"
alias sshnokey="ssh -X -o PubkeyAuthentication=no"
# vim
# https://github.com/Sarcasm/compdb <- Add header files to compile_commands.json
alias vimsrc="compdb -p build/ list > compile_commands.json &> /dev/null; nvim **/*.cpp(N) **/*.cu(N) **/*.hpp(N) **/*.hxx(N) **/*.h(N)" # **/*.c(N) **/*.h(N)
mkbuild () {
mkdir -p /home/wentzell/builds/${PWD##*/}$1
ln -s /home/wentzell/builds/${PWD##*/}$1 build$1
}
alias vimtex='nvim --servername $(basename *.tex.latexmain .tex.latexmain) *.tex content/*.tex(N) settings/*.tex(N)'
# apt
alias apts="apt-cache search"
alias apti="sudo apt-get install"
alias aptr="sudo apt-get remove"
# tmux
#alias tmux="history -w;tmux" # write history file when opening tmux, fix vim colors in tmux,
alias tmux-share="tmux -S /var/tmux/pair_sock new -s shared"
alias tls='tmux list-sessions'
alias tat='tmux attach-session -t'
alias tkill='tmux kill-session -t'
tmuxdev () {
tmux new-session -d -s 'S' -n triqs -c $HOME
tmux neww -n triqs -c $HOME
tmux neww -n Coding -c $HOME
tmux neww -n Coding -c $HOME
tmux neww -n Coding -c $HOME
tmux neww -n Coding -c $HOME
tmux neww -n GCC -c $HOME
tmux neww -n GCC -c $HOME
tmux neww -n ICX -c $HOME
tmux neww -n ICX -c $HOME
tmux neww -n SAN -c $HOME
tmux neww -n SAN -c $HOME
tmux neww -n PROF -c $HOME
tmux neww -n PROF -c $HOME
tmux neww -n DBG -c $HOME
tmux neww -n DBG -c $HOME
tmux send-keys -t S:1 "cd Dropbox/Coding/triqs; clear" C-m
tmux send-keys -t S:2 "cd Dropbox/Coding/triqs/build; clear" C-m
tmux send-keys -t S:3 "cd Dropbox/Coding; clear" C-m
tmux send-keys -t S:4 "cd Dropbox/Coding; clear" C-m
tmux send-keys -t S:5 "cd Dropbox/Coding; clear" C-m
tmux send-keys -t S:6 "cd Dropbox/Coding; clear" C-m
tmux send-keys -t S:7 "cd Dropbox/Coding; module load devenv8/gcc-py3-mkl; source ~/opt/triqs_gcc/share/triqs/triqsvars.sh; clear" C-m
tmux send-keys -t S:8 "cd Dropbox/Coding; module load devenv8/gcc-py3-mkl; source ~/opt/triqs_gcc/share/triqs/triqsvars.sh; clear" C-m
tmux send-keys -t S:9 "cd Dropbox/Coding; module load devenv8/icx-py3-mkl; source ~/opt/triqs_icx/share/triqs/triqsvars.sh; clear" C-m
tmux send-keys -t S:10 "cd Dropbox/Coding; module load devenv8/icx-py3-mkl; source ~/opt/triqs_icx/share/triqs/triqsvars.sh; clear" C-m
tmux send-keys -t S:11 "cd Dropbox/Coding; source ~/opt/triqs_san/share/triqs/triqsvars.sh; clear" C-m
tmux send-keys -t S:12 "cd Dropbox/Coding; source ~/opt/triqs_san/share/triqs/triqsvars.sh; clear" C-m
tmux send-keys -t S:13 "cd Dropbox/Coding; source ~/opt/triqs_prof/share/triqs/triqsvars.sh; export CXXFLAGS=\"-g -gdwarf-4 -fno-omit-frame-pointer -stdlib=libc++ -ffp-contract=fast -march=native\"; clear" C-m
tmux send-keys -t S:14 "cd Dropbox/Coding; source ~/opt/triqs_prof/share/triqs/triqsvars.sh; export CXXFLAGS=\"-g -gdwarf-4 -fno-omit-frame-pointer -stdlib=libc++ -ffp-contract=fast -march=native\"; clear" C-m
tmux send-keys -t S:15 "cd Dropbox/Coding; source ~/opt/triqs_dbg/share/triqs/triqsvars.sh; clear" C-m
tmux send-keys -t S:16 "cd Dropbox/Coding; source ~/opt/triqs_dbg/share/triqs/triqsvars.sh; clear" C-m
tmux selectw -t 1
tmux attach
}
# Develop
cmakedd() {
REAL_BUILD_DIR=$(realpath .)
(cd $(pwd)/..; cmake -B $REAL_BUILD_DIR -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_COLOR_DIAGNOSTICS=ON $@)
}
alias build="cmake --build ."
alias make="make -j 60"
alias ctest="ctest -j 60"
alias pip_upgrade="pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U"
# Clang ignores LIBRARY_PATH
alias activate='source ~/opt/python/bin/activate'
alias ctags='ctags -R --options=$HOME/.ctagsrc'
alias valmem='valgrind --leak-check=full --max-stackframe=4000000'
print_code_CPP='enscript -G -f Courier7 --color -Ecpp -L 90 -C '
print_code_PY='enscript -G -f Courier7 --color -Epython -L 90 -C '
prof() {
rm -f $1.prof* &> /dev/null
LD_PRELOAD=$HOME/opt/gperftools/lib/libprofiler.so CPUPROFILE=$1.prof $@
}
pprint() {
# First argument should be the binary, e.g. executable or python module!
# Second argument is name of profile file
pprof --text --lines $1 $2.prof > $2.prof.txt
head -n 20 $2.prof.txt
pprof --svg --lines $1 $2.prof > $2.prof.lines.svg
pprof --svg $1 $2.prof > $2.prof.svg
pprof --collapsed $1 $2.prof | flamegraph.pl - > $2.prof.flamegraph.svg
#pprof --pdf --lines $1 $2.prof > $2.prof.pdf
#pprof --png --lines $1 $2.prof > $2.prof.png
#chromium-browser $1.prof.svg &
#chromium-browser $1.prof.flamegraph.svg &
#pprof --web --lines $1 $1.prof
}
hprof() {
#CURRENT_DIR=$PWD; mkdir -p hprof; cd hprof;
rm -f $1.hprof* &> /dev/null
LD_PRELOAD=$HOME/opt/gperftools/lib/libtcmalloc.so HEAPPROFILE=$1.hprof $@
#cd $CURRENT_DIR
}
hpprint() {
if [ "$#" -eq 2 ]; then
for f in $(ls $2.hprof.*.heap); do
pprof --text --lines $1 $f > ${f%.*}.txt
head -n 4 ${f%.*}.txt
pprof --svg --lines $1 $f > ${f%.*}.svg
#chromium-browser ${f%.*}.svg &
#pprof --pdf --lines $1 $f > ${f%.*}.pdf
#pprof --web --lines $1 $f
done
elif [ "$#" -eq 3 ]; then
f=$(ls -1 $2.hprof.*$3.heap | head -n 1)
pprof --text --lines $1 $f > ${f%.*}.txt
head -n 5 ${f%.*}.txt
pprof --svg --lines $1 $f > ${f%.*}.svg
#chromium-browser ${f%.*}.svg &
#pprof --pdf --lines $1 $f > ${f%.*}.pdf
#pprof --web --lines $1 $f
fi
}
hpprint_full() {
if [ "$#" -eq 1 ]; then
for f in $1; do
pprof --text --lines $1 $f > ${f%.*}.txt
head -n 4 ${f%.*}.txt
pprof --svg --lines $1 $f > ${f%.*}.svg
chromium-browser ${f%.*}.svg &
#pprof --pdf --lines $1 $f > ${f%.*}.pdf
#pprof --web --lines $1 $f
done
fi
}