-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathprofile
246 lines (214 loc) · 6.39 KB
/
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
# locale stuff
export LANG=en_AU.UTF-8
export LC_CTYPE=en_US.UTF-8
# general shell settings
export PS1='\u@\h:\w\$ ' # basic prompt. get's overwritten later
export FIGNORE="CVS:.DS_Store:.svn:__Alfresco.url"
alias less='less -iM'
export PAGER='less -SFXiMR'
export MAKEFLAGS='-j 3'
complete -d cd mkdir rmdir
# open man pages in Preview.app
if [ -d "/Applications/Preview.app" ]
then
pman () {
man -t "$@" |
( which ps2pdf > /dev/null && ps2pdf - - || cat) |
open -f -a /Applications/Preview.app
}
fi
# our own bin dir at the highest priority, followed by /usr/local/bin
export PATH=~/bin:/usr/local/bin:/usr/local/sbin:"$PATH"
# add a poor facsimile for Linux's `free` if we're on Mac OS
if ! type free > /dev/null 2>&1 && [[ "$(uname -s)" == 'Darwin' ]]
then
alias free="top -s 0 -l 1 -pid 0 -stats pid | grep '^PhysMem: ' | cut -d : -f 2- | tr ',' '\n'"
fi
# I love colour
if ls --version 2> /dev/null | grep -q 'GNU coreutils'
then
export GREP_OPTIONS='--color=auto'
alias ls="ls --color=auto --classify --block-size=\'1"
fi
alias dir='echo Use /bin/ls :\) >&2; false' # I used this to ween myself away from the 'dir' alias
alias mate='echo Use mvim :\) >&2; false'
alias nano='echo Use vim :\) >&2; false'
# handy aliases
alias timestamp='gawk "{now=strftime(\"%F %T \"); print now \$0; fflush(); }"'
# awesome history tracking
export HISTSIZE=100000
export HISTFILESIZE=100000
export HISTCONTROL=ignoredups
export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
export PROMPT_COMMAND='history -a'
shopt -s histappend
PROMPT_COMMAND='history -a; echo "$$ $USER $(history 1)" >> ~/.bash_eternal_history'
# notify of bg job completion immediately
set -o notify
# use Vi mode instead of Emacs mode
set -o vi
# no mail notifications
shopt -u mailwarn
unset MAILCHECK
# check for window resizing whenever the prompt is displayed
shopt -s checkwinsize
# display "user@hostname: dir" in the window title
if [[ "$TERM" =~ ^xterm ]]
then
export PROMPT_COMMAND="$PROMPT_COMMAND; "'echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
fi
# enable rvm if available
if [[ -s "$HOME/.rvm/scripts/rvm" ]]; then
source "$HOME/.rvm/scripts/rvm"
elif [[ -s "/usr/local/rvm/scripts/rvm" ]]; then
source "/usr/local/rvm/scripts/rvm"
fi
[[ -n "$rvm_path" ]] && [[ -r "$rvm_path/scripts/completion" ]] && source "$rvm_path/scripts/completion"
export rvm_pretty_print_flag=1
# set JAVA_HOME if on Mac OS
if [ -z "$JAVA_HOME" -a -d /System/Library/Frameworks/JavaVM.framework/Home ]
then
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
fi
# lesspipe lets us do cool things like view gzipped files
if [ -x "`which lesspipe`" ]
then
eval "$(lesspipe)"
elif [ -x "`which lesspipe.sh`" ]
then
eval "$(lesspipe.sh)"
fi
# alias Debian's `ack-grep` to `ack`
if type -t ack-grep > /dev/null
then
alias ack=ack-grep
fi
# load Homebrew's shell completion
if which brew > /dev/null && [ -f "$(brew --prefix)/Library/Contributions/brew_bash_completion.sh" ]
then
source "$(brew --prefix)/Library/Contributions/brew_bash_completion.sh"
fi
# http://github.com/therubymug/hitch
hitch() {
command hitch "$@"
if [[ -s "$HOME/.hitch_export_authors" ]] ; then source "$HOME/.hitch_export_authors" ; fi
}
alias unhitch='hitch -u'
# filters for XML and JSON
alias xml='xmllint -format - | pygmentize -l xml'
alias json='python -mjson.tool | coderay -json'
# begin awesome colour prompt..
export PS1=""
# add rvm version@gemset
if [[ -n "$rvm_path" ]]
then
function __my_rvm_ps1()
{
[[ -z "$rvm_ruby_string" ]] && return
if [[ -z "$rvm_gemset_name" && "$rvm_sticky_flag" -ne 1 ]]
then
[[ "$rvm_ruby_string" = "system" ]] && echo "system " && return
grep -q -F "default=$rvm_ruby_string" "$rvm_path/config/alias" && return
fi
local full=$(
"$rvm_path/bin/rvm-prompt" i v p g s |
sed \
-e 's/jruby-jruby-/jruby-/' -e 's/ruby-//' \
-e 's/-head/H/' \
-e 's/-2[0-9][0-9][0-9]\.[0-9][0-9]//' \
-e 's/-@/@/' -e 's/-$//')
[ -n "$full" ] && echo "$full "
}
export PS1="$PS1"'\[\033[01;30m\]$(__my_rvm_ps1)'
fi
# add user@host:path
export PS1="$PS1\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w"
function realpath()
{
python -c 'import os,sys;print os.path.realpath(sys.argv[1])' "$@"
}
function first_file_match()
{
local OP="$1"
shift
while [ $# -gt 0 ]
do
if [ $OP "$1" ]
then
echo "$1"
return 0
fi
shift
done
return 1
}
# add git status if available
if which git > /dev/null
then
GIT_COMPLETION_PATH="$(dirname $(realpath "$(which git)"))/../etc/bash_completion.d/git-completion.bash"
fi
if [ ! -f "$GIT_COMPLETION_PATH" ]
then
GIT_COMPLETION_PATH=$(first_file_match -f \
"/usr/local/git/contrib/completion/git-completion.bash" \
"/opt/local/share/doc/git-core/contrib/completion/git-completion.bash" \
"/etc/bash_completion.d/git" \
)
fi
if [ -f "$GIT_COMPLETION_PATH" ]
then
source "$GIT_COMPLETION_PATH"
GIT_PROMPT_PATH="$(dirname "$GIT_COMPLETION_PATH")/git-prompt.sh"
if [ -f "$GIT_PROMPT_PATH" ]; then
source "$GIT_PROMPT_PATH"
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWSTASHSTATE=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
export PS1="$PS1"'\[\033[01;30m\]$(__git_ps1 " (%s)")'
fi
_git_complete() {
local CMD="$1"
shift
if type __git_complete &>/dev/null; then
for ALIAS in "$@"; do
__git_complete "$ALIAS" "_git_$CMD"
done
else
complete -o bashdefault -o default -o nospace -F "_git_$CMD" "$@"
fi
}
_git_complete log gl glp gls glw
_git_complete checkout gco gcp
_git_complete status gs
_git_complete diff gd gdw gds gdsw
_git_complete reset gar garp
_git_complete add ga gap
_git_complete commit gc gca
_git_complete push gp
fi
# finish off the prompt
export PS1="$PS1"'\[\033[00m\]\$ '
# use our own SSL root certificate if present
if [[ -f "/usr/local/etc/openssl/certs/cert.pem" ]]; then
export SSL_CERT_FILE="/usr/local/etc/openssl/certs/cert.pem"
fi
# initialise rbenv
if [[ -x "`which rbenv`" ]]; then
eval "$(rbenv init - --no-rehash)"
fi
# initialize Heroku Toolbelt
if [[ -d "/usr/local/heroku/bin" ]]; then
export PATH="/usr/local/heroku/bin:$PATH"
fi
# initialise autojump
if which brew > /dev/null; then
AUTOJUMP_SCRIPT="$(brew --prefix)/etc/autojump"
if [ -e "$AUTOJUMP_SCRIPT" ]; then
source "$AUTOJUMP_SCRIPT"
fi
fi
# load local shell configuration if present
if [[ -f ~/.bashrc.local ]]
then
source ~/.bashrc.local
fi