-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc_lxplus
240 lines (217 loc) · 5.86 KB
/
.bashrc_lxplus
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
#!/usr/bin/env bash
#--------------------------------------------
set_vars()
{
export SFTDIR=/afs/cern.ch/work/a/acampove/Packages/RK
export PATH+=:$HOME/.local/bin
export STKDIR=/afs/cern.ch/work/a/acampove/stack
export PROMPT_COMMAND=''
export JOBDIR=/afs/cern.ch/user/a/acampove/.grid_jobs/
export EOSHOME=/eos/user/a/acampove/
export EDITOR=vim
export TERM=xterm-256color
export DAVINCI=/afs/cern.ch/work/a/acampove/RK/DaVinci/
export SAMFIND=/afs/cern.ch/work/a/acampove/RK/samplefinder/py/
export PRIDIR=/afs/cern.ch/work/a/acampove/private
export CERNBOX="/eos/user/a/acampove/"
export INSTALL_DIR="/afs/cern.ch/work/a/acampove/Packages/"
export KRB5_CONFIG="/etc/krb5.conf:/afs/cern.ch/user/a/acampove/.kerberos/krb5.conf"
export KRBDIR="/tmp/"
export CONDIR=/afs/cern.ch/work/a/acampove/condir
export SKDR=/afs/cern.ch/work/a/acampove/stack
export EFOP=$SKDR/DaVinci/HltEfficiencyChecker/options
export EFSC=$SKDR/DaVinci/HltEfficiencyChecker/scripts
export RXDR=/afs/cern.ch/work/a/acampove/Packages/RK/rx_hlt_mva
}
#--------------------------------------------
set_alias()
{
alias vim='/afs/cern.ch/work/a/acampove/Packages/nvim/bin/nvim'
alias setupViews="source /cvmfs/sft.cern.ch/lcg/views/setupViews.sh"
alias getsize='du -h --max-depth=0'
alias work='cd /afs/cern.ch/work/a/acampove'
alias mmd='conda deactivate'
alias mml='conda env list'
alias mmr='conda env remove -n '
alias ls='ls --color=auto'
alias sdiff='sdiff -bBWs -w 250'
alias tmuxn="tmux new -s"
alias tmuxa="tmux attach -t"
alias tmuxl="tmux list-sessions"
alias condormont='watch condor_q'
alias tmux_check='systemctl --user status tmux.service'
}
#--------------------------------------------
mma()
{
VENV=$1
conda activate $VENV
if [[ "$VENV" == "rk" ]];then
eval "$(fzf --bash)"
fi
}
#----------------#ZENITY NOTIFICATIONS--------------
disk_usage()
{
PATTERN=$1
du -s *$PATTERN* | awk -F " " '{printf("%s %s\n",$1,$2)}'
}
#---------------------LHCb specific----------------
setLbEnv()
{
SCRIPT=/cvmfs/lhcb.cern.ch/lib/LbEnv
if [ -f $SCRIPT ]; then
. $SCRIPT
fi
}
#---------------------------------------------------
mountCERNBOX()
{
SRC_DIR=/eos/home-a/acampove/
TGT_DIR=
if [[ ! -d $MNT_DIR ]];then
echo "Cannot find $MNT_DIR"
kill -INT $$
fi
sshfs -o idmap=user [email protected]:$MNT_DIR $MNT_DIR
}
#---------------------------------------------------
setView()
{
if [[ ! -z $1 ]] && [[ ! -z $2 ]];then
LCG_REL=$1
ARCH=$2
fi
setupViews $LCG_REL $ARCH
echo "Set:"
echo "LCG:$LCG_REL"
echo "ARCH:$ARCH"
}
#--------------------------------------------------
listBKFiles()
{
BKPATH=$1
if [[ -z $BKPATH ]];then
echo "Path needed"
kill -INT $$
fi
(
setLbEnv
lb-run LHCbDirac/prod bash -c "dirac-bookkeeping-get-files -B \"$BKPATH\""
)
}
#---------------------------------------------------
mountPFS()
{
if [[ ! -z $1 ]];then
MACHINE=$1
else
MACHINE=701
fi
TM=10
SRC_DIR=/publicfs
TRG_DIR=/afs/cern.ch/work/a/acampove/pfs_ucas
if [[ ! -d $TRG_DIR ]];then
echo "Cannot find $TRG_DIR"
kill -INT $$
fi
echo "Caching every $TM seconds in $MACHINE"
sshfs -o cache_timeout=115200 -o attr_timeout=115200 -o cache_stat_timeout=$TM -o cache_dir_timeout=$TM -o cache_link_timeout=$TM -o auto_cache -o idmap=user campoverde@lxslc$MACHINE.ihep.ac.cn:$SRC_DIR $TRG_DIR
}
#------------------------------
unmountPFS()
{
MNT_DIR=/afs/cern.ch/work/a/acampove/pfs_ucas
fusermount -u $MNT_DIR
}
#------------------------------
getLFNFiles()
{
LIST=$1
if [[ -z $LIST ]];then
echo "List of LFNs needed"
kill -INT $$
fi
if [[ ! -f $LIST ]];then
echo "File list $LIST not found"
kill -INT $$
fi
(
setLbEnv
while read FILE;do
echo "$FILE"
lb-run LHCbDirac/prod bash -c "dirac-dms-get-file \"$FILE\""
done < $LIST
)
}
#------------------GHOSTSCRIPT FUNCTIONS------------
gs_merge()
{
if [[ -z $1 ]] || [[ -z $2 ]];then
echo "Usage:"
echo " gs_merge output.pdf *.pdf"
kill -INT $$
fi
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="$1" $2
}
#--------------------------------------------------
conda_init()
{
__conda_setup="$('/afs/cern.ch/work/a/acampove/miniforge3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/afs/cern.ch/work/a/acampove/miniforge3/etc/profile.d/conda.sh" ]; then
. "/afs/cern.ch/work/a/acampove/miniforge3/etc/profile.d/conda.sh"
else
export PATH="/afs/cern.ch/work/a/acampove/miniforge3/bin:$PATH"
fi
fi
unset __conda_setup
if [ -f "/afs/cern.ch/work/a/acampove/miniforge3/etc/profile.d/mamba.sh" ]; then
. "/afs/cern.ch/work/a/acampove/miniforge3/etc/profile.d/mamba.sh"
fi
}
#--------------------------------
git_rc()
{
FILES="$1"
for FILE in ${FILES[@]};do
git add -A $FILE
done
git commit -m "$2"
}
git_ac()
{
FILES="$1"
for FILE in ${FILES[@]};do
if [[ ! -e $FILE ]];then
echo "File/Directory $FILE not found"
kill -INT $$
else
echo "Adding $FILE"
fi
git add $FILE
done
git commit -m "$2"
}
git_acp()
{
git_ac "$1" "$2"
git push origin master
}
git_pull()
{
BRANCH=$(git branch | grep "*" | awk -F " " '{print$2}')
git pull origin $BRANCH
}
#------------------#INSTALLED SOFTWARE--------------
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
shopt -s direxpand
systemctl --user enable --now tmux.service
set_vars
set_alias
conda_init