-
Notifications
You must be signed in to change notification settings - Fork 7
/
.bash_local
276 lines (240 loc) · 6.13 KB
/
.bash_local
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
h=`hostname -s`
case "$h" in
vpn*)
CDATBUILDS="/lgm/uvcdat";;
lapetitechipie*)
ANACONDA_HOME=/lgm/Anaconda;;
oceanonly*)
ANACONDA_HOME=/usr/local/anaconda2;;
crunchy*)
ANACONDA_HOME=${HOME}/anaconda2;;
*Mac*)
CDATBUILDS="/lgm/uvcdat";;
sierra*)
CDATBUILDS="/usr/gapps/uvcdat/chaos_5_x86_64_ib/default"
ANACONDA_HOME=/usr/gapps/uvcdat/anaconda2;;
*)
ANACONDA_HOME=${HOME}/miniconda3;;
esac
case `uname` in
Darwin*)
alias code="/Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron";;
*)
#xmodmap -e "keycode 66 = Shift_L";;
esac
#
# setup ssh-agent
#
# set environment variables if user's agent already exists
[ -z "$SSH_AUTH_SOCK" ] && SSH_AUTH_SOCK=$(ls -l /tmp/ssh-*/agent.* 2> /dev/null | grep $(whoami) | awk '{print $9}')
[ -z "$SSH_AGENT_PID" -a -z `echo $SSH_AUTH_SOCK | cut -d. -f2` ] && SSH_AGENT_PID=$((`echo $SSH_AUTH_SOCK | cut -d. -f2` + 1))
[ -n "$SSH_AUTH_SOCK" ] && export SSH_AUTH_SOCK
[ -n "$SSH_AGENT_PID" ] && export SSH_AGENT_PID
# start agent if necessary
if [ -z $SSH_AGENT_PID ] && [ -z $SSH_TTY ]; then # if no agent & not in ssh
eval `ssh-agent -s` > /dev/null
fi
# setup addition of keys when needed
if [ -z "$SSH_TTY" ] ; then # if not using ssh
ssh-add -l > /dev/null # check for keys
if [ $? -ne 0 ] ; then
alias ssh='ssh-add -l > /dev/null || ssh-add && unalias ssh ; ssh'
if [ -f "/usr/lib/ssh/x11-ssh-askpass" ] ; then
SSH_ASKPASS="/usr/lib/ssh/x11-ssh-askpass" ; export SSH_ASKPASS
fi
fi
fi
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add;
}
fonts=( doom banner big bulbhead digital epic larry3d ogre puffy pyramid small smkeyboard )
## Accessing remote machines
alias xt=xtightvncviewer
alias xtm="xtightvncviewer meryem"
alias xts="xtightvncviewer sofia"
## Git
alias gcl='${HOME}/bin/git-clean-local.pyi -s -V'
alias gst='git status'
alias gbr='for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r'
alias gb='for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort'
## Conda
alias cenv='conda env list | grep \* | cut -d" " -f1'
notrailing() {
echo "Removing white spaces at end of lines for: $1"
find . -name $1 -print0 | xargs -r0 sed -e 's/[[:blank:]]\+$//' -i
}
gcb() {
echo "RECEIVED: $# args"
if [ $# == 1 ]; then
remote="origin"
else
remote="$2"
fi
echo "SEt remote to: ${remote}"
echo "Creating branch $1 on remote ${remote}"
git checkout -b $1
git push -u ${remote} HEAD:$1
}
gcbd() {
gcb $1 devel
}
# Python
alias pb="python setup.py install"
alias p="ipython"
PYTHONSTARTUP=${HOME}/.pythonrc
export PATH=${PATH}:/Library/TeX/Distributions/.DefaultTeX/Contents/Programs/x86_64
## Make sure my python paths do not get mangled
unset DYLD_LIBRARY_PATH
unset DYLD_FALLBACK_LIBRARY_PATH
unset LD_LIBRARY_PATH
unset PYTHONPATH
unset UVCDAT_SETUP_PATH
# Given a dir list most recent file
# extra args are files to exclude/ignore
function mostrecentdir {
DIRS=`ls -lrt $1 | awk '{print $9}'`
EXCLUDES=${@:2}
for EXCLUDE in $EXCLUDES
do
DIRS=`echo $DIRS | sed "s/${EXCLUDE}//g"`
done
echo `echo ${DIRS} | tr " " "\n" | tail -n1`
}
smv() {
rsync -az --remove-source-files "$@";
}
# Newer setpy using anaconda envs
setpy() {
if [ $# == 0 ]; then
pth=$(mostrecentdir ${ANACONDA_HOME}/envs _build)
else
pth=$1
fi
echo "Using "${pth}" conda environment"
conda activate ${pth}
if [ `uname` == "Darwin" ]; then
export DYLD_FALLBACK_LIBRARY_PATH=${ANACONDA_HOME}/envs/${pth}/lib
fi
}
iPuvcdat() {
if [ $# == 0 ]; then
PKG=vcs
else
PKG=$1
fi
if [ $# == 2 ]; then
CMD=spb
else
CMD='python setup.py install'
fi
if [ $PKG == "vcs" ]; then
CMD=$CMD" --old-and-unmanageable"
fi
where=$(pwd)
cd $(dirname $(dirname $(readlink ${HOME}/.bash_local)))
cd uvcdat/Packages/${PKG}
${CMD}
cd ${where}
}
iP() {
if [ $# == 0 ]; then
PKG=vcs
else
PKG=$1
fi
if [ $# == 2 ]; then
CMD=spb
else
CMD='python setup.py install'
fi
if [ $PKG == "vcs" ]; then
CMD=$CMD" --old-and-unmanageable"
fi
where=$(pwd)
cd $(dirname $(dirname $(readlink ${HOME}/.bash_local)))
cd ${PKG}
${CMD}
cd ${where}
}
spb() {
good_python=`which python`
sudo ${good_python} setup.py install
}
addline() {
sed -i.bak -n 'H;${x;s/x=vcs.init()\n/x=vcs.init()\nx.drawlogooff()\n/;p;}' $1
}
# Editors
unalias emacs
case "$h" in
omar)
alias vi="vim";;
*)
alias vi="vim";;
esac
export EDITOR='vi'
# ls aliases
alias ls='ls -h'
# mosh aliases
alias lc='export LC_CTYPE=en_US'
alias lcu='export LC_CTYPE=en_US.UTF-8'
PROMPT_ADDRESS_COLOR=${_BLUE}
PROMPT_COMMAND_HIST_INDEX_COLOR=${_GOLD}
export PS1=${PS1//\W/\w}
export HISTCONTROL=erasedups
export HISTSIZE=1000000
export HISTFILESIZE=1000000
export TMOUT=0
stty ixany
stty ixoff -ixon
unset DYLD_LIBRARY_PATH
unset DYLD_FALLBACK_LIBRARY_PATH
unset LD_LIBRARY_PATH
unset PYTHONPATH
unset UVCDAT_SETUP_PATH
echo "ANACONDA:"${ANACONDA_HOME}
#export PATH=${ANACONDA_HOME}/bin:$PATH
#source ${ANACONDA_HOME}/etc/profile.d/conda.sh
#conda activate
# Stuff I don't want from Gavin's repo
export CDPATH=.:..
unset TOMCAT_HOME
unset CATALINA_HOME
unset PROJECT
unset TRASH
unset OLDPWD
unset XTERM_SHELL
unset JRUBY_HOME
unset COMMAND_MODE
unset JAVA_HOME
unset DEVTOOLS
unset DBUS_LAUNCHD_SESSION_BUS_SOCKET
unset JAXB_HOME
unset CLASS_ROOT
unset XTERM_LOCAL
unset XTERM_VERSION
unset M2_HOME
unset GROOVY_HOME
unset CLASSPATH
unset ARCHIVE
unset STASH
unset X11_PREFS_DOMAIN
unset ESGF_SITE_ROOT
unset __CF_USER_TEXT_ENCODING
unset R_HOME
unset JAR_PATH
unset XTERM_LOCALE
unset XTERM
if [ "${GREP_COLORS}" == "" ]
then
export GREP_COLORS=${GREP_COLOR}
fi
unset GREP_COLOR
unset OPAL_PREFIX
echo "Do not forget to run:"
echo "sudo pam_tally2 --user doutriaux1 --reset"