forked from ryanb/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathshrc
193 lines (165 loc) · 5.96 KB
/
shrc
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
## GENERAL ##
alias editor="atom"
alias dotfiles="editor ~/.dotfiles"
alias shrc="editor ~/.dotfiles/shrc"
alias privaterc="editor ~/.dotfiles/privaterc"
alias ios="open -a iPhone\ Simulator"
alias chzsh="chsh -s /bin/zsh"
alias ch="open -a \"Google Chrome\""
alias refresh="source ~/.zshrc"
alias tmux="tmux -2" # -2 forces tmux to use 256 colors
alias json="pbpaste | jq . | pbcopy" # prettifies JSON in clipboard and stores back in clipboard
alias st="open -a SourceTree"
alias v="st ." # nmeumonic: 'version control'
alias a="atom ."
alias f="fdir"
## GIT ##
alias ggraph="git log --all --graph --decorate --oneline --simplify-by-decoration"
alias gll="git log -n 20 | head"
alias gb="git branch --sort=-committerdate | head"
# to delete remote branch call, eg: git push origin :my_branch
alias gdd="git branch -d"
alias gs="git status"
alias gsa="git stash apply"
alias gp="git push"
alias g-="git checkout -"
alias gpr="git pull --rebase"
alias gds="git diff --cached"
alias guncommit="git reset --soft HEAD^"
alias gunc="git reset --soft HEAD^"
alias gempty="git commit -am \"empty\" --allow-empty"
alias gamend="git commit --amend --no-edit"
alias ggc="git commit -m"
alias gcf="git commit --fixup"
alias gch="git checkout"
# eg. make fixup commit: "gcf {hash_of_commit_to_fixup}". Then gri {commit_hash}^ and it will auto reorder
alias gri="git rebase -i --autosquash"
alias grc="git rebase --continue"
alias gwip="git commit -m \"WIP\""
alias gdw="git diff --word-diff"
alias gcb="current_branch"
alias ggp="git push -u origin `(current_branch)`"
alias gpu="git push -u origin"
## HEROKU ##
alias hl="heroku logs -t --remote"
alias hlogs="hl"
alias hconfig='heroku config --remote'
alias hconf="hconfig"
alias hc="heroku run rails c --remote"
alias hcp="hc production"
alias hmigrate="heroku run rake db:migrate --remote"
alias hm="hmigrate"
alias hr="heroku run rake"
alias hrs="heroku restart --remote"
alias ha="heroku addons:open"
alias hbackup="heroku pg:backups capture --remote"
# to copy down in one line: heroku pgbackups:restore DATABASE `heroku pgbackups:url --remote production` --remote dev
alias hake="heroku run rake"
alias hpb="heroku features:enable preboot -r"
alias hpbo="heroku features:disable preboot -r"
alias nr="heroku addons:open newrelic"
alias pt="heroku addons:open papertrail"
## PHP ##
alias phplog="tail -f /Applications/MAMP/logs/php_error.log"
alias vhosts="vim /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf"
## POSTGRES ##
alias pglog="tail -f /usr/local/var/postgres/server.log"
# run this if getting an error starting postgres after os x crash
alias pgdeletepid="rm /usr/local/var/postgres/postmaster.pid"
alias pgstart="pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start"
## RUBY/RAILS ##
alias be="bundle exec"
alias rc="bundle exec rails c"
alias bspec="bundle exec rspec"
alias ms="make start"
alias springer="bundle exec spring stop && bundle exec spring start"
alias springrspec="bundle exec spring binstub rspec"
alias routes="bin/rake routes"
alias routesg="routes | grep"
alias rmg="bin/rails db:migrate"
alias rmgt="bin/rails db:migrate RAILS_ENV=test"
## MISCELLANEOUS ##
# add ruby gem info to the man command
alias man="gem man -ls"
alias kts='tmux ls | awk '\''{print $1}'\'' | sed '\''s/://g'\'' | xargs -I{} tmux kill-session -t {}'
# fix oh-my-zshissue with '#' being misinterpreted by bower
alias bower='noglob bower'
# update rbenv ruby definitions. I prefer the rbenv-update plugin to this
alias update_rebenv="cd ~/.rbenv/plugins/ruby-build; git pull"
## PATH ##
PATH=/usr/local/bin:/usr/local/sbin:/usr/local/lib/node:$PATH
PATH=./bin:./vendor/bundle/bin:$PATH
PATH=$PATH:/opt/local/bin
PATH=$PATH:~/.dotfiles/scripts:~/.dotfiles/scripts/private
PATH=$PATH:~/bin
PATH=$PATH:~/go/bin
PATH=$PATH:~/Library/Android/sdk/tools
PATH=$PATH:~/Library/Android/sdk/platform-tools
PATH=~/.rbenv/bin:~/.rbenv/bin/shims:$PATH
eval "$(rbenv init -)"
PATH="./bin:$PATH"
export PATH
#export NODE_PATH=/usr/local/bin/node
export GOPATH=~/go
## FUNCTIONS ##
function ports() { # Find which process is using 3000 or supplied port, then run kill -9 {pid}
local port="${1:-3000}"
lsof -wni tcp:${port};
}
function kill_port() { # Finds which process is using 3000 or supplied port and kills it
local port="${1:-3000}"
kill -9 $(lsof -i tcp:${port} -t)
}
# mkdir recursively and then cd to it
function cdm () { mkdir -p "$@" && eval cd "\"\$$#\""; }
# find directory by name, recursive. Max depth is 6 or optionally specified
function fdir() {
local depth="${2:-6}"
find . -maxdepth $depth -type d -name "*${1}*"
}
# simple HTTP server. just type `server` for server on 4000
function server() {
local port="${1:-4000}"
python -m SimpleHTTPServer "$port"
}
function ghinit() { # eg ghinit stevehanson/dotfiles
echo "git remote add origin [email protected]:${1}.git"
}
function pow() {
echo "http://${1}.10.0.1.96.xip.io/"
}
function light() {
local syntax="${1}"
pbpaste | highlight --syntax=$syntax --verbose -O rtf | pbcopy
}
function sandbox() {
cd $(~/bin/generate_sandbox.py)
}
function hideHidden(){
defaults write com.apple.finder AppleShowAllFiles -bool NO
killall Finder
}
function showHidden(){
defaults write com.apple.finder AppleShowAllFiles -bool YES
killall Finder
}
function showBundle() {
bundle show $1 | xargs subl
}
# will dump a backup of the database, where $1 is the remote name
# eg: dump production && import myapp_development
function dump() curl -o latest.dump `heroku pgbackups:url --remote $1`
# will import a backup of the database, where $1 is the database name
function import() pg_restore --verbose --clean --no-acl --no-owner -h localhost -U `whoami` -d $1 latest.dump
# alias "c {x}" to do "cd ~/dev/{x}" with tab completion
c() { cd ~/dev/$1; }
_c() { _files -W ~/dev -/; }
compdef _c c
# alias "s {x}" to do "cd ~/Sites/{x}" with tab completion
s() { cd ~/Sites/$1; }
_s() { _files -W ~/Sites -/; }
compdef _s s
# alias "h {x}" to do "cd ~/{x}" with tab completion
h() { cd ~/$1; }
_h() { _files -W ~/ -/; }
compdef _h h