-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbashrc
249 lines (207 loc) · 5.84 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
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
# ***DO THIS ON NEW MACHINE***
# cd $HOME
# git clone https://github.com/monarin/goodstuffs
# In system bashrc, add
# [ -f "$HOME/goodstuffs/bashrc" ] && . "$HOME/goodstuffs/bashrc"
# [ -f "$HOME/goodstuffs/bashrc_history" ] && . "$HOME/goodstuffs/bashrc_history"
alias viper="ssh -YAC [email protected]"
alias dials="ssh -YAC [email protected]"
alias pslogin="ssh -YAC [email protected]"
alias psdev="ssh -YAC [email protected]"
alias atbfs3="ssh [email protected]"
alias moje="ssh [email protected]"
alias cori="ssh -Y [email protected]"
alias oakr="ssh -YAC [email protected]"
alias smdev="ssh [email protected]"
alias s3df="ssh s3dflogin.slac.stanford.edu"
alias frontier="ssh [email protected]"
alias crusher="ssh [email protected]"
alias ascent="ssh [email protected]"
alias perlmutter="ssh [email protected]"
alias tmodaq="ssh -YC tmo-daq -l tmoopr"
alias rixdaq="ssh -YC rix-daq -l rixopr"
alias mcclogin="ssh mcclogin.slac.stanford.edu"
alias lclssrv="ssh acclegr@lcls-srv01"
alias ll='ls -l'
alias delpyc="find . -name \"*. pyc\" -delete"
alias now='date "+%Y-%m-%d+%H%M%S"'
vman() {
man "$@" | col -b | vi -R -
}
sve() {
DESTPATH="${HOME}/Save/$@_`now`"
echo "Saved to $DESTPATH"
cp -a $@ $DESTPATH
}
gdbpy() {
gdb `which python`
}
mypath() {
MYPATH=$HOME
if [ "$1" != '' ]; then
MYPATH=$@
fi
}
gccthis() {
gcc -pthread -B /reg/g/psdm/sw/conda2/inst/envs/ps-0.0.6/compiler_compat -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/reg/g/psdm/sw/conda2/inst/envs/ps-0.0.6/lib/python3.5/site-packages/numpy/core/include -I/reg/neh/home/monarin/lcls2/install/include -I/reg/g/psdm/sw/conda2/inst/envs/ps-0.0.6/include/python3.5m -c ringbuf.cc -o ringbuf -std=c++11
}
prof_py() {
python -m cProfile -s tottime $1
}
prof_strace_py() {
strace -ttt -f -o $$.log python $1
}
prof_perf_py() {
perf record python $1
echo "run perf report to see results"
}
pyver() {
pyver=$(python -c "import sys; print(str(sys.version_info.major)+'.'+str(sys.version_info.minor))")
echo $pyver
}
export EDITOR=vim
export GIT_EDITOR=vim
# Enable tab completion
source $HOME/goodstuffs/git-completion.bash
# colors!
green="\[\033[0;32m\]"
blue="\[\033[0;34m\]"
purple="\[\033[0;35m\]"
cyan="\[\033[0;36m\]"
reset="\[\033[0m\]"
# Change command prompt
source $HOME/goodstuffs/git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE=1
# '\u' adds the name of the current user to the prompt
# '\$(__git_ps1)' adds git-related stuff
# '\W' adds the name of the current directory
myprompt=""
export PS1="$purple\u$cyan@\h$green\$(__git_ps1)$blue \W $myprompt$reset"
grr() {
# -I ignores binary files
grep -I --exclude \*.class --exclude \*.pyc --exclude-dir .git --exclude-dir .svn -r "$@"
}
cutniq() {
grep -v 'Binary file' | cut -d: -f1 | uniq
}
see_disk_quota() {
df -h $HOME
}
see_kerberos_cred() {
klist
}
see_dir_total() {
du -shc ./*
}
git_aa() {
mod_files=($(git status | grep modified: | gawk '{ print $2}'))
length=${#mod_files[@]}
for ((i=0; i<length; i++))
do
echo "adding $i: '${mod_files[i]}'"
git add ${mod_files[i]}
done
}
git_set_remote_ssh() {
git remote set-url origin [email protected]:monarin/$1.git
}
docker_clean() {
arr=( $(docker images | grep "<none>" | gawk '{ print $3 }') )
for imgid in ${arr[*]}
do
printf "remove %s\n" $imgid
docker rmi -f $imgid
done
}
rm_swp() {
arr=( $(find . -name "*.swp") )
for fname in ${arr[*]}
do
printf "remove %s\n" $fname
rm $fname
done
}
sve_git_aa() {
mod_files=($(git status | grep modified: | gawk '{ print $3}'))
length=${#mod_files[@]}
for ((i=0; i<length; i++))
do
f_basename="$(basename "${mod_files[i]}")"
f_dirname="$(dirname "${mod_files[i]}")"
echo "saving $i: '${mod_files[i]}' to ~/Save"
pushd $f_dirname
sve $f_basename
popd
done
}
lstoday() {
ls "$@" -al --time-style=+%D | grep $(date +%D)
}
sacctj() {
sacct -j $1 --format=JobIDRaw,JobName%12,NodeList,Start,End,Elapsed,REQCPUS,ALLOCTRES%25
}
activate_pytorch(){
export PYTHONPATH=$PYTHONPATH:/sdf/scratch/users/m/monarin/sw
}
psf() {
ps -p $1 -o pid,vsz=MEMORY -o user,group=GROUP -o cls,pri,rtprio -o comm,args=ARGS | cat
}
sinfof() {
sinfo -o "%30N %10c %10m %35f %10G "
}
sqf() {
squeue $@ -o "%.18i %15j %.8u %.8T %20S %.10M %.6D %R"
}
prc(){
isort "$@"
black "$@"
ruff check "$@"
#flake8 "$@"
}
open_latest() {
local file
prefix=${1}
file=$(ls -t ${prefix} 2>/dev/null | head -n 1)
if [[ -n "$file" ]]; then
vim "$file"
else
echo "No ${prefix} files found." >&2
fi
}
tail_latest() {
local file
prefix=${1}
file=$(ls -t ${prefix} 2>/dev/null | head -n 1)
if [[ -n "$file" ]]; then
tail -f "$file"
else
echo "No ${prefix} files found." >&2
fi
}
pip_who_needs() {
if [ -z "$1" ]; then
echo "Usage: pip_who_needs <package-name>"
return 1
fi
local target="$1"
echo "🔍 Checking which user-installed packages require '$target'..."
pip list --user --format=freeze | cut -d= -f1 | while read pkg; do
deps=$(pip show "$pkg" | awk -F': ' '/Requires:/ {print $2}')
if echo "$deps" | grep -wq "$target"; then
echo "📦 $pkg depends on $target"
fi
done
}
# Function to enable pyenv only when needed
use_pyenv() {
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv >/dev/null 2>&1; then
eval "$(pyenv init -)"
echo "pyenv initialized."
echo "Available versions:"
pyenv versions
else
echo "pyenv not found in $PYENV_ROOT. Please install it first."
fi
}