/
aliases
261 lines (220 loc) · 6.56 KB
/
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
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
# Aliases
# #######
# Some example alias instructions
# If these are enabled they will be used instead of any instructions
# they may mask. For example, alias rm='rm -i' will mask the rm
# application. To override the alias instruction use a \ before, ie
# \rm will call the real rm not the alias.
# Interactive operation...
# alias rm='rm -i'
# alias cp='cp -i'
# alias mv='mv -i'
# Default to human readable figures
alias df='df -h'
alias du='du -h'
# Misc :)
# alias less='less -r' # raw control characters
# alias whence='type -a' # where, of a sort
alias grep='grep --color' # show differences in colour
alias myips="ifconfig | grep 'inet ' | grep -v 127.0.0.1 | cut -d\ -f2"
# Some shortcuts for different directory listings
# alias ls='ls -hF --color=tty' # classify files in colour
# alias dir='ls --color=auto --format=vertical'
# alias vdir='ls --color=auto --format=long'
alias ll='ls -l' # long list
alias la='ls -A' # all but . and ..
# alias l='ls -CF' #
alias mkdir='mkdir -p'
# Moving up directories
alias ..='cd ..'
alias ...='cd .. && cd ..'
alias ....='cd .. && cd .. && cd ..'
alias .....='cd .. && cd .. && cd .. && cd ..'
alias pc="pwd | ruby -pe '\$_.strip!' | pbcopy"
function m {
files=$(ls *.tmproj 2> /dev/null)
if [ "$files" != "" ]; then
open $files
else
mate .
fi
}
# Rails/Padrino aliases
function sc {
if [ -f './script/console' ]; then
./script/console $*
elif [ -f './script/rails' ]; then
./script/rails console $*
elif [ -f './config/apps.rb' ]; then
padrino console $*
else
rails console $*
fi
}
function sr {
if [ -f './script/rails' ]; then
./script/rails runner $*
else
./script/runner $*
fi
}
function ss {
if [ -f './config/unicorn.rb' ]; then
echo "$*" | grep -E "(^| )-p " > /dev/null 2>&1
if [ $? != 1 ]; then
PORT=""
else
PORT="-p 3000"
fi
if [ -f './script/rails' ]; then
bundle exec unicorn_rails $PORT $*
else
bundle exec unicorn $PORT $*
fi
elif [ -f './script/rails' ]; then
./script/rails server $*
elif [ -f './script/server' ]; then
./script/server $*
elif [ -f './config/apps.rb' ]; then
padrino start $*
elif [ -f './bin/rails' ]; then
rails server $*
else
ruby -r webrick -e "trap('INT') { @server.stop }; (@server = WEBrick::HTTPServer.new(:DocumentRoot => Dir.pwd, :Port => 3000)).start"
fi
}
function sg {
if [ -f './script/rails' ]; then
./script/rails generate $*
elif [ -f './config/apps.rb' ]; then
padrino g $*
elif [ -f './bin/rails' ]; then
rails generate $*
else
./script/generate $*
fi
}
alias tfd='tail -f log/development.log'
alias tfp='tail -f log/production.log'
alias atr='autotest -rails'
alias rdm='rake db:migrate && rake db:test:prepare'
alias rr='rake routes'
alias rt='ruby -I test'
alias rtu='rake test:units'
alias bec='bundle exec cucumber'
alias fms='foreman start'
alias b='bundle'
alias bi="b install -j 8 && b binstubs --all"
alias bu="b update"
alias be="b exec"
alias bo="b open"
alias binit="bi && b package && echo 'vendor/ruby' >> .gitignore"
# Aliases for git
alias gl='git pull --rebase'
alias gp='git push'
alias gps='git push --force-with-lease'
alias gb='git branch -a -v'
alias gst='git status -sb'
alias gss='ruby ~/.submodule_status.rb `pwd`'
alias gd="git diff | $DIFF_TOOL"
alias gdi="git diff --ignore-space-change | $DIFF_TOOL"
alias gdc="git diff --cached | $DIFF_TOOL"
alias gdic="git diff --cached --ignore-space-change | $DIFF_TOOL"
alias gi='git commit'
alias gc='git checkout'
alias gcl='git clone'
alias grc='git rebase --continue'
alias gri='git rebase -i'
alias gt='gittower .'
alias gh='github'
alias gpr='git push -u && github browse'
alias showme='ERROR_SCREENSHOTS=true $(fc -ln -1)'
function git-clean {
git checkout master && \
git branch --merged | grep -v "\*" | xargs -n 1 git branch -d && \
git remote prune origin
}
function git-add-remote-branch {
git push origin origin:refs/heads/$1
}
function git-add-remote-branch-and-checkout {
git push origin origin:refs/heads/$1
git checkout --track -b $1 origin/$1
}
function git-remove-remote-branch {
git push origin :heads/$1
}
_gl_git ()
{
local i c=1 command="pull" __git_dir __git_repo_path
local cur words cword prev
local __git_cmd_idx=0
_get_comp_words_by_ref -n =: cur words cword prev
_git_pull
}
_gp_git ()
{
local i c=1 command="push" __git_dir __git_repo_path
local cur words cword prev
local __git_cmd_idx=0
_get_comp_words_by_ref -n =: cur words cword prev
_git_push
}
_gc_git ()
{
local i c=1 command="checkout" __git_dir __git_repo_path
local cur words cword prev
local __git_cmd_idx=0
_get_comp_words_by_ref -n =: cur words cword prev
_git_checkout
}
_gi_git ()
{
local i c=1 command="commit" __git_dir __git_repo_path
local cur words cword prev
local __git_cmd_idx=0
_get_comp_words_by_ref -n =: cur words cword prev
_git_commit
}
complete -o bashdefault -o default -o nospace -F _gl_git gl 2>/dev/null \
|| complete -o default -o nospace -F _gl_git gl
complete -o bashdefault -o default -o nospace -F _gp_git gp 2>/dev/null \
|| complete -o default -o nospace -F _gp_git gp
complete -o bashdefault -o default -o nospace -F _git_status gst 2>/dev/null \
|| complete -o default -o nospace -F _git_status gst
complete -o bashdefault -o default -o nospace -F _gc_git gc 2>/dev/null \
|| complete -o default -o nospace -F _gc_git gc
complete -o bashdefault -o default -o nospace -F _gi_git gi 2>/dev/null \
|| complete -o default -o nospace -F _gi_git gi
# Aliases for ruby
# use completion and require rubygems by default for irb
alias irb='irb -r irb/completion'
alias gemdir='gem env gemdir'
# really awesome function, 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`
}
function gemdoc {
GEMDIR=`gemdir`/doc
open $GEMDIR/`ls $GEMDIR | grep $1 | sort | tail -1`/rdoc/index.html
}
function mategem {
GEMDIR=`gemdir`/gems
mate $GEMDIR/`ls $GEMDIR | grep $1 | sort | tail -1`
}
function _gem_list {
COMPREPLY=($(compgen -W "$(ls `gemdir`/gems)" -- "${COMP_WORDS[COMP_CWORD]}"))
}
function _gem_doc_list {
COMPREPLY=($(compgen -W "$(ls `gemdir`/doc)" -- "${COMP_WORDS[COMP_CWORD]}"))
}
complete -F _gem_list cdgem
complete -F _gem_list mategem
complete -F _gem_doc_list gemdoc
function keynote_highlight_ruby {
pbpaste | highlight -O rtf --font-size 24 --font Menlo --style moe --src-lang ruby | pbcopy
}
alias docker-startup='docker-machine start osxdock && eval "$(docker-machine env osxdock)"'
alias docker-shutdown='docker-machine stop osxdock'