-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbash_aliases
More file actions
249 lines (193 loc) · 8.61 KB
/
Copy pathbash_aliases
File metadata and controls
249 lines (193 loc) · 8.61 KB
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
#!/bin/bash
# ----------------------------------------------------------------------
# | Navigation |
# ----------------------------------------------------------------------
alias ~="cd ~"
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias cd..="cd .."
# ----------------------------------------------------------------------
# | Git |
# ----------------------------------------------------------------------
alias gba="git branch -a"
alias gcm="git checkout master"
alias glpp="git log --pretty=oneline"
alias gs="git status"
alias gd="git diff"
alias gp="git pull"
alias gci="git commit --interactive"
alias ga="git add"
alias gmt="git mergetool"
alias gpom="git push origin master"
alias gpsm="git push staging master"
alias gppm="git push production master"
alias gr="git rebase -i HEAD~10"
alias gc="git commit -m "
alias gri="git add --all && git commit -m 'WIP' && git rebase -i HEAD~10"
alias rebase_master="git checkout master && git pull origin master && git checkout - && git rebase master"
alias rebase_staging="git checkout staging && git pull origin staging && git checkout - && git rebase staging"
alias merge_master="git checkout master && git pull --rebase && git checkout - && git rebase master && git checkout master && git merge -"
alias delete_merged="git branch --merged | grep -v '^* master$' | grep -v '^ master$' | grep -v '^* staging$' | grep -v '^ staging$' | xargs git branch -d"
alias clean_branches="git checkout master && git pull origin master && git checkout staging && git pull origin staging && git remote update --prune && delete_merged"
# ----------------------------------------------------------------------
# | Rails |
# ----------------------------------------------------------------------
alias rc="bin/rails c"
alias rs="bin/rails s"
alias gib="gem install bundler"
alias gibp="gem install bundler --pre"
alias bi="bundle install"
alias bu="bundle update"
alias bx="bundle exec"
alias bs="bundle exec rspec"
alias bir="bundle install --relock"
alias brake="bin/rake"
alias brails="bin/rails"
alias migrate="bin/rake db:migrate"
alias rspec="bundle exec rspec"
alias thin="bundle exec thin"
alias remakedb="bin/rake db:drop db:create db:migrate && bin/rake db:seed"
alias remaketest="bin/rake db:drop db:create db:migrate RAILS_ENV=test"
alias remakedbs="bin/rake db:drop db:create db:migrate && bin/rake db:seed && bin/rake db:drop db:create db:migrate RAILS_ENV=test"
# ----------------------------------------------------------------------
# | Heroku |
# ----------------------------------------------------------------------
alias prod_logs="heroku logs -t --remote production"
alias stag_logs="heroku logs -t --remote staging"
alias migrate_stag="heroku run rake db:migrate --remote staging"
alias migrate_prod="heroku run rake db:migrate --remote production"
alias reset_stag_db="heroku pg:reset --remote staging DATABASE && heroku run rake db:migrate --remote staging && heroku run rake db:seed --remote staging && heroku restart --remote staging"
alias reset_prod_db="heroku pg:reset --remote production DATABASE && heroku run rake db:migrate --remote production && heroku run rake db:seed --remote production && heroku restart --remote production"
# ----------------------------------------------------------------------
# | Network |
# ----------------------------------------------------------------------
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if [ "$OS" == "osx" ]; then
alias local-ip="ipconfig getifaddr en1"
elif [ "$OS" == "ubuntu" ]; then
alias local-ip="ifconfig | \
grep 'inet addr' | \
grep -v '127.0.0.1' | \
cut -d: -f2 | \
cut -d' ' -f1"
fi
# ----------------------------------------------------------------------
# | Package Managers |
# ----------------------------------------------------------------------
# npm
# https://docs.npmjs.com/
if [ -x "$(command -v npm)" ]; then
alias npmi="npm install"
alias npmr="npm uninstall"
alias npms="npm search"
alias npmu="npm update"
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# OS specific package managers
if [ "$OS" == "osx" ]; then
# Homebrew
# http://brew.sh/
if [ -x "$(command -v brew)" ]; then
alias brewd="brew doctor"
alias brewi="brew install"
alias brewr="brew uninstall"
alias brews="brew search"
alias brewu="brew update && \
brew upgrade && \
brew cleanup"
fi
elif [ "$OS" == "ubuntu" ]; then
# Advanced Packaging Tool
alias apti="sudo apt-get install"
alias aptr="sudo apt-get remove"
alias apts="sudo apt-cache search"
alias aptu="sudo apt-get update && \
sudo apt-get upgrade"
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Update
if [ "$OS" == "osx" ]; then
alias update="sudo softwareupdate --install --all && \
brewu && \
npmi -g npm && \
npmu -g"
elif [ "$OS" == "ubuntu" ]; then
alias update="aptu && \
npmi -g npm && \
npmu -g"
fi
# ----------------------------------------------------------------------
# | Shorter Commands |
# ----------------------------------------------------------------------
alias :q="exit"
alias c="clear"
alias ch="history -c && > ~/.bash_history"
alias e="vim"
alias g="git"
alias ll="ls -l"
alias m="man"
alias map="xargs -n1"
alias q="exit"
alias rm="rm -rf"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Copy to clipboard
if [ "$OS" == "osx" ]; then
alias cc="pbcopy"
elif [ "$OS" == "ubuntu" ]; then
alias cc="xclip -selection clip"
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Empty Trash
if [ "$OS" == "osx" ]; then
# Empty the trash, the main HDD and on all mounted volumes
# and clear Apple’s system logs to improve shell startup speed
alias empty-trash="sudo rm -frv /Volumes/*/.Trashes && \
sudo rm -frv ~/.Trash &&
sudo rm -frv /private/var/log/asl/*.asl"
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Hide/Show files
if [ "$OS" == "osx" ]; then
# Hide/Show desktop icons
alias hide-desktop-icons="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
alias show-desktop-icons="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"
# Hide/Show hidden files in Finder
alias hide-hidden-files="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
alias show-hidden-files="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
elif [ "$OS" == "ubuntu" ]; then
# Hide/Show desktop icons
alias hide-desktop-icons="gsettings set org.gnome.desktop.background show-desktop-icons false"
alias show-desktop-icons="gsettings set org.gnome.desktop.background show-desktop-icons true"
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Lock screen
if [ "$OS" == "osx" ]; then
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Open
if [ "$OS" == "osx" ]; then
alias o="open"
elif [ "$OS" == "ubuntu" ]; then
alias o="xdg-open"
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if [ "$OS" == "osx" ]; then
alias use-node="brew unlink iojs && brew link --force node"
alias use-iojs="brew unlink node && brew link --force iojs"
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Open sublime and SourceTree
if [ "$OS" == "osx" ]; then
alias code="atom . && stree && open -a ~/Applications/Google\ Chrome.app 'http://localhost:3000' && rs"
elif [ "$OS" == "ubuntu" ]; then
alias code="subl . && rs"
fi
# ----------------------------------------------------------------------
# | Tunneling / External tools |
# ----------------------------------------------------------------------
tunnel() {
"/usr/local/bin/lt --port $1"
}