-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbashrc
229 lines (195 loc) · 7.03 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
#
# ~/.bashrc
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output. So make sure this doesn't display
# anything or bad things will happen !
#
# Default editor
if [[ -z "$EDITOR" ]]; then
export EDITOR="/usr/local/bin/atom --wait"
fi
# Path - Python
PATH=${PATH}:$HOME/Library/Python/2.7/bin
# Path - Google Storage
PATH=${PATH}:$HOME/gsutil
# Path - Homebrew etc
PATH=/usr/local/bin:${PATH}
# Path - Dotfiles
PATH=$HOME/.dotfiles_local/bin:$HOME/.dotfiles/bin:${PATH}
export PATH
# Python
export PYTHONPATH=/usr/local/lib/python:$PYTHONPATH
################################################################################
################################################################################
# Test for an interactive shell. There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
[[ $- != *i* ]] && return
################################################################################
################################################################################
#
# Interactive shell options
#
# Bash won't get SIGWINCH if another process is in the foreground.
# Enable checkwinsize so that bash will check the terminal size when
# it regains control. #65623
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
shopt -s checkwinsize
# Enable history appending instead of overwriting. #139609
shopt -s histappend
#
# Tab completion
#
# Git tab completion
source ~/.gitfiles/git-completion.sh
# Git-flow tab completion
source ~/.gitfiles/git-flow-completion.bash
# Homebrew tab completion
source `/usr/local/bin/brew --prefix`/Library/Contributions/brew_bash_completion.sh
#
# Liquidprompt for bash
#
source ~/.dotfiles/liquidprompt/liquidprompt
#
# LS COLORS
#
# color normal bold
# ---------- ------ ------
# black a A
# red b B
# green c C
# brown d D
# blue e E
# magenta f F
# cyan g G
# light grey h H
# default x
DIR=Gx
SYM_LINK=Gx
SOCKET=Fx
PIPE=dx
EXE=Cx
BLOCK_SP=Dx
CHAR_SP=Dx
EXE_SUID=hb
EXE_GUID=ad
DIR_STICKY=Gx
DIR_WO_STICKY=Gx
## Defined-above LS colors
export LSCOLORS="$DIR$SYM_LINK$SOCKET$PIPE$EXE\
$BLOCK_SP$CHAR_SP$EXE_SUID$EXE_GUID\
$DIR_STICKY$DIR_WO_STICKY"
## Michael's LS colors
#export LSCOLORS=ExFxCxDxBxegedabagacad
##
## Good old LS aliases
##
export CLICOLOR="yes"
export LS_OPTIONS='-F'
alias ls='ls $LS_OPTIONS'
alias l='ls -CF'
alias ll='ls -hl'
alias la='ls -a'
alias lla='ls -lah'
## Faster parent navigation
alias ..='cd ..'
alias ...='cd .. ; cd ..'
################################################################################
## SSHFS remote filesystem mounts
################################################################################
#alias mntHEPEX="sshfs -o allow_other,workaround=all jcj7h@hepex.phys.virginia.edu: ~/mnt/hepex_drive/"
#alias mntCMSRAID="sshfs -o allow_other,workaround=all jcj7h@hepex.phys.virginia.edu:/raids/rnas ~/mnt/cms_raid"
#alias mntVPT="sshfs -o allow_other,workaround=all vpt@hepex.phys.virginia.edu: ~/mnt/vpt_drive/"
#alias mntALL="mntHEPEX | mntCMSRAID | mntVPT"
################################################################################
## Directory bookmarks
################################################################################
# Usage:
# cd <bookmark> -- go to bookmark location
# show -- show all bookmarks
# save <bookmark> -- save current working directory as bookmark
if [ ! -f ~/.dirs ]; then # if doesn't exist, create it
touch ~/.dirs
fi
alias show='cat ~/.dirs'
save (){
command sed "/!$/d" ~/.dirs > ~/.dirs1; \mv ~/.dirs1 ~/.dirs; echo "$@"=\"`pwd`\" >> ~/.dirs; source ~/.dirs ;
}
source ~/.dirs # Initialization for the above 'save' facility: source the .dirs file
shopt -s cdable_vars # set the bash option so that no '$' is required when using the above facility
################################################################################
## Finder label color
# From: http://superuser.com/questions/168927/mac-os-x-how-to-change-the-color-label-of-files-from-the-terminal
################################################################################
label(){
if [ $# -lt 2 ]; then
echo "USAGE: label [0-7] file1 [file2] ..."
echo "Sets the Finder label (color) for files"
echo "Default colors:"
echo " 0 No color"
echo " 1 Orange"
echo " 2 Red"
echo " 3 Yellow"
echo " 4 Blue"
echo " 5 Purple"
echo " 6 Green"
echo " 7 Gray"
else
osascript - "$@" << EOF
on run argv
set labelIndex to (item 1 of argv as number)
repeat with i from 2 to (count of argv)
tell application "Finder"
set theFile to POSIX file (item i of argv) as alias
set label index of theFile to labelIndex
end tell
end repeat
end run
EOF
fi
}
################################################################################
### Other useful stuff
################################################################################
# Case insensitive grep
alias g='grep -i'
# Easy find
alias f='find . -iname'
# List the size of all folders and files
alias ducks='du -cks * | sort -rn|head -11'
# Launch top without having to use 'man'
alias top='top -o cpu'
# Convenience alias for system log
alias systail='tail -f /var/log/system.log'
# Show what commands you use the most
alias profileme="history | awk '{print \$2}' | awk 'BEGIN{FS=\"|\"}{print \$1}' | sort | uniq -c | sort -n | tail -n 20 | sort -nr"
# Show a graphical representation of the current sub directories
alias tree="ls -R | grep ':$' | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'"
# Install git ignore files
function gi() { curl -L -s https://www.gitignore.io/api/$@ ;}
### oga2flac alias
### Why? (Why not flac -8f *.oga)? Because of Max. That's why.
### Part of the purpose (sigh) is to trash metadata because metaflac can't read it.
### Hence, "flac -8f *.oga" will fail, because it preserves tagging.
#alias oga2flac="flac -d *.oga && flac --best *.wav && rm *.wav *.oga && ls"
################################################################################
## External imports
################################################################################
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
################################################################################
## Anything after this was appended by installers
################################################################################