-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbash_aliases
192 lines (170 loc) · 4.56 KB
/
bash_aliases
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
# Some useful aliases
alias aliases='echo "waiting for MacVim to close…"; mvim -f ~/.bash_aliases && source ~/.bash_aliases'
#######
# git #
#######
# also see utilities/bash_completion.d/git-aliases
alias g='git'
alias ga="git add"
alias gb='git branch --verbose'
alias gba='git branch --verbose -a'
alias gc='git commit --verbose'
alias gca='git commit --verbose --all'
if [ "$system_name" == 'Darwin' ]; then
function gd {
git diff --ignore-space-change $@
}
else
alias gd='git diff --ignore-space-change'
fi
alias gl='git pull'
alias gm="git merge"
alias gnp='git --no-pager'
alias gp='git push'
alias gs="git stash"
alias gst='git status'
alias gsu="git submodule update"
alias gsui="git submodule update --init"
alias gitrm="git stat | grep deleted | awk '{print $3}' | xargs git rm"
function gsearch {
for branch in `git branch | sed 's/\*//'`; do echo $branch:; git ls-tree -r --name-only $branch | grep "$1"; done
}
function gco {
if [ -z "$1" ]; then
git checkout master
else
git checkout $1
fi
}
function st {
if [ -d ".svn" ]; then
svn status
else
git status
fi
}
# Gitx.app (http://rowanj.github.io/gitx/)
alias gx="gitx"
alias gxc="gitx --commit"
alias gxd="git diff --ignore-space-change | gitx --diff"
# Gitup.app (https://github.com/git-up/GitUp)
alias gu='gitup open'
alias guc='gitup commit'
alias gum='gitup map'
alias gus='gitup stash'
########
# RUBY #
########
# use readline, completion and require rubygems by default for irb
alias irb='irb --simple-prompt -r irb/completion -rubygems'
export GEMDIR=`gem env gemdir`
# use: cdgem <gem name>, cd's into your gems directory and opens gem that best
# matches the gem name provided
function cdgem {
cd $GEMDIR/gems
cd `ls | grep $1 | sort | tail -1`
}
_cdgemcomplete() {
COMPREPLY=($(compgen -W '$(ls $GEMDIR/gems)' -- ${COMP_WORDS[COMP_CWORD]}))
return 0
}
complete -o default -o nospace -F _cdgemcomplete cdgem
# use: gemdoc <gem name>, opens gem docs from the gem docs directory that best
# matches the gem name provided
# (hat tip: http://stephencelis.com/archive/2008/6/bashfully-yours-gem-shortcuts)
gemdoc() {
open -a firefox $GEMDIR/doc/`ls $GEMDIR/doc | grep $1 | sort | tail -1`/rdoc/index.html
}
_gemdocomplete() {
COMPREPLY=($(compgen -W '$(ls $GEMDIR/doc)' -- ${COMP_WORDS[COMP_CWORD]}))
return 0
}
complete -o default -o nospace -F _gemdocomplete gemdoc
# use: vimgem <gem name>, cd's into your gems directory and opens gem that best
# matches the gem name provided in gvim
function vimgem {
gvim -c NERDTree $GEMDIR/gems/`ls $GEMDIR/gems | grep $1 | sort | tail -1`
}
function mategem {
mate $GEMDIR/gems/`ls $GEMDIR/gems | grep $1 | sort | tail -1`
}
complete -o default -o nospace -F _cdgemcomplete vimgem mategem
alias rtags='ctags -R --languages=ruby --exclude=.git --exclude=log .'
#########
# RAILS #
#########
alias ss='script/server' # start up the beast
alias sr='kill -USR2 `cat tmp/pids/mongrel.pid`' # restart detached Mongrel
alias sst='kill `cat tmp/pids/mongrel.pid`' # restart detached Mongrel
alias sc='script/console'
alias a='rspactor' # makes autotesting even quicker
##############
# TENSORFLOW #
##############
alias tf='cd ~/code/tensorflow; source bin/activate'
alias tfq='deactivate'
#########################################
# default options for standard commands #
#########################################
alias ls='ls -h'
alias which='which -a'
########
# misc #
########
alias cleanvimswaps="find . -iregex '.*\.sw[po]$' -delete"
alias h='history'
alias l="ls -lah"
alias la='ls -ah --color=auto'
alias ll="ls -lh --color=auto"
alias lla='ls -alh --color=auto'
alias m='mate'
alias m.='mate .'
alias ql='qlmanage -p 2>/dev/null'
function cdd {
if [ -z "$1" ]; then
cd ~/code
else
cd ~/code/$1
fi
}
_cddcomplete() {
local cur
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $( compgen -S/ -d ~/code/$cur | grep -v '\.git/$' | cut -b 18- ) )
}
complete -o nospace -F _cddcomplete cdd
# Make a directory and cd into it
function mcd() {
mkdir -p "$1" && cd "$1"
}
# Make a temp directory and cd into it
function mtd() {
local dir
dir=$(mktemp -d)
if test -n "$dir"
then
if test -d "$dir"
then
echo "$dir"
cd "$dir"
else
echo "mktemp directory $dir does not exist"
fi
else
echo "mktemp didn't work"
fi
}
# cd up n directories
function cdup {
ups=""
for i in $(seq 1 $1)
do
ups=$ups"../"
done
cd $ups
}
alias ..='cd ..;' # can then do .. .. .. to move up multiple directories.
alias ...='cdup 2'
alias ....='cdup 3'
alias .....='cdup 4'
# vi:filetype=sh