-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.bash_profile
340 lines (294 loc) · 10 KB
/
.bash_profile
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# Set CLICOLOR if you want Ansi Colors in iTerm2
export CLICOLOR=1
export TERM=xterm-256color
txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
txtcyn='\e[0;36m' # Cyan
txtwht='\e[0;37m' # White
bldblk='\e[1;30m' # Black - Bold
bldred='\e[1;31m' # Red
bldgrn='\e[1;32m' # Green
bldylw='\e[1;33m' # Yellow
bldblu='\e[1;34m' # Blue
bldpur='\e[1;35m' # Purple
bldcyn='\e[1;36m' # Cyan
bldwht='\e[1;37m' # White
unkblk='\e[4;30m' # Black - Underline
undred='\e[4;31m' # Red
undgrn='\e[4;32m' # Green
undylw='\e[4;33m' # Yellow
undblu='\e[4;34m' # Blue
undpur='\e[4;35m' # Purple
undcyn='\e[4;36m' # Cyan
undwht='\e[4;37m' # White
bakblk='\e[40m' # Black - Background
bakred='\e[41m' # Red
badgrn='\e[42m' # Green
bakylw='\e[43m' # Yellow
bakblu='\e[44m' # Blue
bakpur='\e[45m' # Purple
bakcyn='\e[46m' # Cyan
bakwht='\e[47m' # White
txtrst='\e[0m' # Text Reset - Useful for avoiding color bleed
# Initialize autojump
[ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh
export GITAWAREPROMPT=~/.bash/git-aware-prompt
source "${GITAWAREPROMPT}/main.sh"
export PS1="\[$undpur\][\W]\[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\[$bldblu\] >> \[$txtrst\]"
# Ignore/delete repeated duplicate consecutive commands in history
export HISTCONTROL=erasedups
export HISTSIZE="NOTHING"
export HISTFILESIZE="NOTHING" # no limit
shopt -s histappend # global history
#export PROMPT_COMMAND='history -a'
# ALIASES #
###########
#export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
#alias mq='/Users/vincentyang/Desktop/IdentityMind/MessageQueue/mq/bin/imqbrokerd -vmargs "-Xms128m -Xmx512m -Xss256k" -name identitymind&'
#alias redis='/Users/vincentyang/Desktop/IdentityMind/Redis/redis-3.0.2/src/redis-server'
#alias mysql='mysql.server start'
#alias mysqle='mysql.server stop'
alias reload='unalias -a && source ~/.bash_profile'
alias aeonneo='cd ~/Dropbox/AeonNeo/'
alias life='cd ~/Dropbox/AeonNeo/Life'
alias dotfiles='cd ~/Dropbox/AeonNeo/dotfiles'
alias projects='cd ~/Dropbox/AeonNeo/Projects'
alias sublime='open /Applications/Sublime\ Text\ 2.app/'
alias now='cd /Users/VincentYang/Dropbox/AeonNeo/UC-Davis/Senior/Spring/260'
alias bcnc='cd ~/Dropbox/AeonNeo/UC\-Davis/BCNC'
alias dcg='cd ~/Dropbox/AeonNeo/UC\-Davis/DCG'
alias :q='exit'
alias proj='cd ~/Dropbox/AeonNeo/Projects/'
alias bish='cd ~/Dropbox/AeonNeo/Projects/Integrated-Security-Simulation/'
alias wd='pwd'
alias .='cd ..'
alias ..='cd ../..'
alias ...='cd ../../..'
alias ....='cd ../../../..'
alias ga='git add .'
alias gm='git mergetool'
#alias vi="vim -S ~/.vimrc"
alias matlab="/Applications/MATLAB_R2015b.app/bin/matlab -nodesktop"
alias hd="cd ~/Dropbox/AeonNeo/UC-Davis/HackDavis/"
alias grad="cd ~/Dropbox/AeonNeo/Career/Grad"
alias digitalo="ssh [email protected]"
alias matloff="cd ~/Dropbox/AeonNeo/UC-Davis/freqparcoord-extension"
alias rs="rscript"
alias p3="python3.6"
alias rload="echo 'library(freqparcoord.cd, lib.loc = \"~/R/\")' && R CMD INSTALL -l ~/R"
alias clamd="/usr/local/sbin/clamd"
alias tls='tmux list-sessions'
alias ta='tmux a -t'
alias tn='tmux new -s'
#alias emacs="/usr/local/Cellar/emacs/25.2/Emacs.app/Contents/MacOS/Emacs -nw"
# TODO: make this work even in existing tmux session
t() {
if [ $# -eq 0 ]
then
tmux attach -t default -d || tmux new -s default
#elif [ "$1" = "a" ]
#then
# tmux detach
# t r
# tmux detach
# t w
# tmux detach
# t
elif [ "$1" = "r" ]
then
tmux attach -t research || tmux new -s research
elif [ "$1" = "w" ]
then
tmux attach -t work || tmux new -s work
elif [ "$1" = "c" ]
then
tmux attach -t club || tmux new -s club
else
tmux attach -t "$1" || tmux new -s "$1"
fi
}
tk() {
if [ "$1" = "d" ]
then
tmux kill-session -t default
elif [ "$1" = "r" ]
then
tmux kill-session -t research
elif [ "$1" = "w" ]
then
tmux kill-session -t work
elif [ "$1" = "c" ]
then
tmux kill-session -t club
else
echo Nothing to kill!
fi
}
c() {
if [ $# -eq 0 ]
then
ls
else
cd "$1"
ls
fi
}
# Download music from youtube or soundcloud.
# If it is a youtube link, download from youtube.
# Otherwise, download from soundcloud
m() {
if [[ $1 == *"youtube"* ]]; then
youtube-dl -i -x --audio-format mp3 $1
# Use regex to remove the hash
elif [[ $1 == *"soundcloud"* ]]; then
scdl -l $1
fi
# Spotify: https://github.com/ritiek/spotify-downloader
# Use spotify to get appropriate artist/other tags
}
# Setting PATH for Python 3.4
# # The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}"
export PATH
export HISTTIMEFORMAT="%d/%m/%y %T "
#Colors specified here: http://geoff.greer.fm/lscolors/
export LSCOLORS=bxfxcxdxhxegedabagacad
export GREP_OPTIONS='--color=auto'
source `brew --prefix git`/etc/bash_completion.d/git-completion.bash
alias g='git'
# Autocomplete for 'g' as well
complete -o default -o nospace -F _git g
# Misc
#copy output of last command to clipboard
alias cl="fc -e -|pbcopy"
# top
alias cpu='top -o cpu'
alias mem='top -o rsize' # memory
# copy the working directory path
alias cpwd='pwd|tr -d "\n"|pbcopy'
# DNS (with update thanks to @blanco)
alias flush="sudo killall -HUP mDNSResponder"
# share history between terminal sessions
alias he="history -a" # export history
alias hi="history -n" # import history
# Get your current public IP
alias ip="curl icanhazip.com"
# ls better
alias la="ls -aF"
alias ld="ls -ld"
alias ll="ls -lh"
alias lt='ls -At1 && echo "------Oldest--"'
alias ltr='ls -Art1 && echo "------Newest--"'
# mount all connected Firewire disks
alias mountall='system_profiler SPFireWireDataType | grep "BSD Name: disk.$" | sed "s/^.*: //" | (while read i; do /usr/sbin/diskutil mountDisk $i; done)'
# unmount them all
alias unmountall='system_profiler SPFireWireDataType | grep "BSD Name: disk.$" | sed "s/^.*: //" | (while read i; do /usr/sbin/diskutil unmountDisk $i; done)'
# recursively delete Dropbox conflicted files
alias rmdbc="find . -name *\ \(*conflicted* -exec rm {} \;"
# mute the system volume
alias stfu="osascript -e 'set volume output muted true'"
# time machine log
alias tmlog="syslog -F '\$Time \$Message' -k Sender com.apple.backupd-auto -k Time ge -30m | tail -n 1"
# list TODO/FIX lines from the current project
alias todos="ack -n --nogroup '(TODO|FIX(ME)?):'"
lfind() {
sudo find / -type f -size +100000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
}
# interactive fasd
#alias zi="fasd -e cd -i"
# extract: Extract most know archives with one command
# ---------------------------------------------------------
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export PATH="/Applications/SWI-Prolog.app/Contents/MacOS:$PATH"
_gen_fzf_default_opts() {
local base03="234"
local base02="235"
local base01="240"
local base00="241"
local base0="244"
local base1="245"
local base2="254"
local base3="230"
local yellow="136"
local orange="166"
local red="160"
local magenta="125"
local violet="61"
local blue="33"
local cyan="37"
local green="64"
# If the file is text, pretty print with rougify. Otherwise, notify of invalid (binary) file.
# rougify is using theme base16.solarized.dark, which is set in .rvm/gems/ruby-2.3.0/gems/rouge-2.0.7/lib/rouge
# rougify is faster than coderay and pygmentize
export FZF_DEFAULT_OPTS="--height 40% --color fg:124,bg:-1,hl:$orange,fg+:15,bg+:52,hl+:231,info:$base00,prompt:196,spinner:208,pointer:196,marker:208
--preview '(if file {} | grep -q text; then rougify {} 2> /dev/null; else echo Invalid File Type; fi)'
--reverse
"
}
_gen_fzf_default_opts
# Make FZF red colorscheme
f() {
FILE=$(fzf)
echo $FILE
if (( ${#FILE} > 0 )); then
vi $FILE
fi
}
# Will return non-zero status if the current directory is not managed by git
is_in_git_repo() {
git rev-parse HEAD > /dev/null 2>&1
}
fzf-down() {
fzf --height 50% "$@" --border
}
gh() {
is_in_git_repo || return
git log --date=short --format="%C(magenta) %ar %C(cyan)%h%C(green)%d %s (%an)" --graph --color=always |
fzf-down --ansi --no-sort --reverse --multi --bind 'ctrl-s:toggle-sort' \
--header 'Press CTRL-S to toggle sort' \
--preview 'grep -o "[a-f0-9]\{7,\}" <<< {} | xargs git show --color=always | head -'$LINES |
grep -o "[a-f0-9]\{7,\}"
}
rmd () {
pandoc $1 | lynx -stdin
}
# List all items in brew list with size
bl() {
for pkg in `brew list -f1 | egrep -v '\.|\.\.'`
do echo $pkg `brew info $pkg | egrep '[0-9]* files, ' | sed 's/^.*[0-9]* files, \(.*\)).*$/\1/'`
done
}
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
export PATH="/usr/local/opt/openssl/bin:$PATH"
export PATH="/usr/local/opt/python@2/bin:$PATH"
##
# Your previous /Users/VincentYang/.bash_profile file was backed up as /Users/VincentYang/.bash_profile.macports-saved_2018-07-11_at_23:23:52
##
# MacPorts Installer addition on 2018-07-11_at_23:23:52: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.