-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy path.bashrc
279 lines (242 loc) · 7.08 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
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
# .bashrc
# Author: Nicola Paolucci <nick@durdn.com>
# Source: http://github.com/durdn/cfg/.bashrc
#Global options {{{
export HISTFILESIZE=999999
export HISTSIZE=999999
export HISTCONTROL=ignoredups:ignorespace
shopt -s histappend
shopt -s checkwinsize
shopt -s progcomp
#!! sets vi mode for shell
set -o vi
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
#path should have durdn config bin folder
export PATH=$HOME/.cfg/bin:$PATH
# }}}
#Prompt customisation {{{
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\[\1\]/'
}
function proml {
local WHITE="\[\033[1;37m\]"
local BLACK="\[\033[0;30m\]"
local BLUE="\[\033[0;34m\]"
local LIGHT_BLUE="\[\033[1;34m\]"
local CYAN="\[\033[0;36m\]"
local RED="\[\033[0;31m\]"
local LIGHT_RED="\[\033[1;31m\]"
local GREEN="\[\033[0;32m\]"
local GREEN2="\[\033[0;32m\]"
local LIGHT_GREEN="\[\033[1;32m\]"
local WHITE="\[\033[1;37m\]"
local LIGHT_GRAY="\[\033[0;37m\]"
local MAGENTA="\[\033[1;35m\]"
local LIGHT_GRAY2="\[\033[0;37m\]"
local DARK_GRAY="\[\033[1;30m\]"
case $TERM in
xterm*)
TITLEBAR='\[\033]0;\u@\h:\w\007\]'
;;
*)
TITLEBAR=""
;;
esac
PS1="${TITLEBAR}\
$LIGHT_GRAY2[$DARK_GRAY\u$LIGHT_GRAY2]\
$LIGHT_GRAY2[$LIGHT_BLUE\h$LIGHT_GRAY2:$BLUE\w$LIGHT_GRAY2]$RED\$(parse_git_branch)$LIGHT_GRAY2\
$LIGHT_GRAY\n\$ "
PS2='> '
PS4='+ '
}
proml
# }}}
# durdn/cfg related commands {{{
function dur {
case $1 in
create|cr)
ssh durdn@durdn.com "cd /home/durdn/git && mkdir $2.git && cd $2.git && git --bare init-db"
;;
list|li)
ssh durdn@durdn.com "cd /home/durdn/git && ls -C"
;;
clone|cl)
git clone ssh://durdn@durdn.com/~/git/$2.git
;;
install|i)
/usr/bin/env python $HOME/.cfg/install.py
;;
reinstall|re)
curl https://raw.github.com/durdn/cfg/master/install.py -o - | python
;;
move|mv)
git remote add bitbucket git@bitbucket.org:durdn/$(basename $(pwd)).git
git push --all bitbucket
;;
trackall|tr)
#track all remote branches of a project
for remote in $(git branch -r | grep -v master ); do git checkout --track $remote ; done
;;
help|h|*)
echo "[dur]dn shell automation tools - (c) 2011 Nicola Paolucci nick@durdn.com"
echo "commands available:"
echo " [cr]eate, [li]st, [cl]one"
echo " [i]nstall,[m]o[v]e, [re]install"
echo " [tr]ackall], [h]elp"
;;
esac
}
# }}}
# Bashmarks from https://github.com/huyng/bashmarks (see copyright there) {{{
# USAGE:
# s bookmarkname - saves the curr dir as bookmarkname
# g bookmarkname - jumps to the that bookmark
# g b[TAB] - tab completion is available
# l - list all bookmarks
# save current directory to bookmarks
touch ~/.sdirs
function s {
cat ~/.sdirs | grep -v "export DIR_$1=" > ~/.sdirs1
mv ~/.sdirs1 ~/.sdirs
echo "export DIR_$1=$PWD" >> ~/.sdirs
}
# jump to bookmark
function g {
source ~/.sdirs
cd $(eval $(echo echo $(echo \$DIR_$1)))
}
# list bookmarks with dirnam
function l {
source ~/.sdirs
env | grep "^DIR_" | cut -c5- | grep "^.*="
}
# list bookmarks without dirname
function _l {
source ~/.sdirs
env | grep "^DIR_" | cut -c5- | grep "^.*=" | cut -f1 -d "="
}
# completion command for g
function _gcomp {
local curw
COMPREPLY=()
curw=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=($(compgen -W '`_l`' -- $curw))
return 0
}
# bind completion command for g to _gcomp
complete -F _gcomp g
# }}}
# Fixes hg/mercurial {{{
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
# }}}
#Global aliases {{{
alias gs='git status '
alias ga='git add '
alias gb='git branch '
alias gc='git commit '
alias gd='git diff '
alias go='git checkout '
alias stashup='git stash && git svn rebase && git stash apply'
function list-patch {
git log --oneline --decorate --numstat -1 $1 | tail -n +2 | awk {'print $3'}
}
function f {
find . -type f | grep -v .svn | grep -v .git | grep -i $1
}
function gr {
find . -type f | grep -v .svn | grep -v .git | xargs grep -i $1 | grep -v Binary
}
# }}}
# Linux specific config {{{
if [ $(uname) == "Linux" ]; then
shopt -s autocd
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
#alias assumed="git ls-files -v | grep ^[a-z] | sed -e 's/^h\ //'"
alias assumed="git ls-files -v | grep ^h | sed -e 's/^h\ //'"
# Add an "alert" alias for long running commands. Use like so: sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
#apt aliases
alias apt='sudo apt-get'
alias cs='sudo apt-cache search'
alias ls='ls --color'
alias ll='ls -l --color'
alias la='ls -al --color'
alias less='less -R'
#project aliases
#alias tarot="screen -c ./screen-tarot.config"
#PATH=$PATH:$HOME/dev/apps/node/bin
fi
# }}}
# OSX specific config {{{
if [ $(uname) == "Darwin" ]; then
#export PATH=/usr/local/mysql/bin:$HOME/bin:/opt/local/sbin:/opt/local/bin:$PATH
#export PATH=/Users/nick/.clj/bin:$PATH
export PATH=/usr/local/bin:/usr/local/Cellar/python/2.7.2/bin:/usr/local/share/python:$HOME/bin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH
#aliases
alias ls='ls -G'
alias ll='ls -lG'
alias la='ls -alG'
alias less='less -R'
alias fnd='open -a Finder'
alias gitx='open -a GitX'
alias grp='grep -RIi'
alias assumed="git ls-files -v | grep ^[a-z] | sed -e 's/^h\ //'"
#open macvim
function gvim {
if [ -e $1 ];
then open -a MacVim $1;
else touch $1 && open -a MacVim $1;
fi
}
#setup sqlplus
export DYLD_LIBRARY_PATH="/opt/local/lib/oracle:/Users/nick/dev/apps/sqlplus-ic-10.2"
export TNS_ADMIN="/Users/nick/dev/apps/sqlplus-ic-10.2"
# export PATH=/Users/nick/dev/apps/sqlplus-ic-10.2:$PATH
#project aliases
alias tarot="screen -c ./screen-tarot.config"
alias atg="screen -c ./screen-atg.config"
#sourcing
#source /Users/nick/dev/envs/boi-env/bin/activate
#source /Users/nick/.philips
#source git bash completion from homebrew on OSX
#source /usr/local/etc/bash_completion.d/git-completion.bash
#setup RVM on OSX
#[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
#setup rbenv
#export PATH="$HOME/.rbenv/bin:$PATH"
#eval "$(rbenv init -)"
fi
# }}}
# MINGW32_NT-5.1 (winxp) specific config {{{
if [ $(uname) == "MINGW32_NT-5.1" ]; then
alias ls='ls --color'
alias ll='ls -l --color'
alias la='ls -al --color'
alias less='less -R'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# }}}
# Clients configs {{{
# Delixl config {{{
if [ $(uname -n) == "ubuntu" ] && [ $(whoami) == "developer" ];
then source ~/.delixl-aliases
fi
# }}}
# }}}