This repository has been archived by the owner on Jan 26, 2023. It is now read-only.
forked from blamattina/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
aliases
223 lines (183 loc) · 6.41 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
# install vim plugins
alias plug-install='vim -u "$HOME"/.vimrc.bundles +PlugInstall +PlugClean! +qa'
alias dotfiles='code ~/git/dotfiles'
alias dot='dotfiles'
alias notes='insiders ~/Dropbox/notes/work'
alias c='code .'
alias pubExt='rm -rf $HOME/.vscode/extensions/vs-code-extensions && cp -R /Users/duhl/git/vs-code-extensions $HOME/.vscode/extensions'
# deploy
alias gri='git branch --set-upstream-to=origin/master && git rebase -i'
alias gprm='git pull --rebase origin master'
# git
alias reload!='. ~/.zshrc && . ~/.zshrc.local'
alias rebuild!='rcdn -vd ~/git/dotfiles/dotfiles-1 && rcdn -vd ~/git/dotfiles/dotfiles-local && rcup -vd ~/git/dotfiles/dotfiles-1 && rcup -vd ~/git/dotfiles/dotfiles-local'
alias gwho='git shortlog -n -s --no-merges'
alias gc='git checkout'
alias gcb='git checkout -b'
alias gcbm=checkoutFromMaster
function checkoutFromMaster() {
gcb $1 origin/master;
}
alias gclear='git checkout -- . && git status'
#logging
alias glm='git log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short --committer="duhl"'
alias gl="git log --graph --pretty=format:'%Cred%h%Creset %an: %s - %Creset %C(yellow)%d%Creset %Cgreen(%cr)%Creset' --abbrev-commit --date=relative"
alias glh='git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short'
# committing
alias ga='git add -A'
alias gca='git add -A && git commit -m'
alias gcin='git add -A && git commit -n -m'
alias gci='git add -A && git commit -n'
alias gcamend='git add -A && git commit --amend'
alias gcc='git checkout -- .'
alias guc='git reset --soft HEAD~1'
alias grm='git reset HEAD'
alias gremove='git reset HEAD && git status'
# get latest master on local master without checking out master
alias gfm='git fetch origin master:master'
alias gmm='git merge master --no-edit'
alias gpm='gfm && gmm'
alias gpmm='git prune && rm .git/gc.log && gpm'
# !!DANGER!! will lose changes
alias grevertall='git reset --hard HEAD~1'
alias gun='git reset --hard HEAD'
alias gkilleverything='git reset --hard origin/master'
alias grevert='git checkout origin/master '
# pushing and pulling
alias gpush='git push origin HEAD'
alias gpa='git push --no-verify'
alias gp='rm -f .git/gc.log && git pull'
alias gpr='git pull --rebase'
# rebase is saying, "instead of building my features on that old commit, build them all on this new commit"
alias grm='gf && git rebase origin/master'
alias gf='git fetch --all'
alias gpp='gpr && gpush'
alias lint='node_modules/.bin/eslint --rulesdir grunt_tasks/eslint/rules'
alias gclean='git remote prune origin && git gc && git clean -dfx && git stash clear'
# ignore files
alias gignore="git update-index --assume-unchanged"
alias gstopignore="git update-index --no-assume-unchanged"
alias gcm='git checkout master'
alias gcmp='gcm && gpr'
alias gmp='gm && gpr'
# clean directory
alias gcl='git clean -fdx'
# branches
alias gbd='git branch -D'
alias gb='printBranches'
alias gbm='git branch -m' # rename a branch
alias createremote="createRemoteBranch"
alias deleteremote="deleteRemoteBranch"
alias pushremote="pushRemoteBranch"
alias pullremote="pullRemoteBranch"
alias diffremote="diffRemoteBranch"
alias gs="git status" # upgrade your git if -sb breaks for you. it's fun.
alias seediff="git difftool master"
alias gremote='git remote set-url origin [email protected]/danieluhl/' # last param should be the github repo name.git - [email protected]/danieluhl/my_repo.git
alias gm='git merge'
alias gms='git merge --squash'
# git take theirs (follow with file path to take theirs on)
alias gtt='git checkout --theirs'
alias gmtheirs='git merge --strategy-option theirs'
alias gmours='git merge --strategy-option ours'
# diffing
alias gd='git diff --color | diff-so-fancy'
alias gds='git diff --staged --color | diff-so-fancy'
alias gdn="git diff --name-only master --color | diff-so-fancy | tee ~/git/patch/names.patch"
alias gdm="git diff master --color | diff-so-fancy"
# ********** non git ***********
alias lsa='ls -la'
alias toucheverything='find . -exec touch {} \; &'
# open in sublime
alias subl='open -a Sublime\ Text '
alias stt='subl .'
alias pf='open -a "path finder" ./'
# open in atom
alias att='open -a atom .'
# open in vs code
alias vtt='code ./'
# npm install from global registry
alias npmi=npminstall
function npminstall() {
eval "npm install $1 --registry https://registry.npmjs.org/"
}
# call functions
alias go="changeDirectory"
alias deps="traceDependenciesByLeaf"
# run browser-sync
alias bs="browser-sync start --directory --server"
# functions
function changeDirectory()
{
eval "cd ~/git/$1";
}
# traces all dependencies to see if they're there
function traceDependenciesByLeaf()
{
eval "grunt deps --depth 1 --leaf $1"
}
function printBranches()
{
eval 'for k in `git branch | sed s/^..//`; do echo -e `git log -1 --pretty=format:"%Cgreen%ci %Cred%cr%Creset" $k --`\\t"$k";done | sort'
}
# pushes the current branch to the same named remote
function pushRemoteBranch()
{
currentBranch="$(git symbolic-ref HEAD 2>/dev/null)";
currentBranch=${currentBranch##refs/heads/}
eval "git push -f origin $currentBranch";
}
function pullRemoteBranch()
{
currentBranch="$(git symbolic-ref HEAD 2>/dev/null)";
currentBranch=${currentBranch##refs/heads/}
eval "git pull origin $currentBranch";
}
function diffRemoteBranch()
{
currentBranch="$(git symbolic-ref HEAD 2>/dev/null)";
currentBranch=${currentBranch##refs/heads/}
repo=${PWD##*/}
eval "git diff --full-index origin/$currentBranch" | tee ~/git/patch/$repo/$currentBranch.patch
}
# create a remote branch and set upstream
function createRemoteBranch()
{
eval "git push -u origin $1:$1";
}
# delete a remote branch
function deleteRemoteBranch()
{
eval "git push origin :$1";
}
function deleteBranch()
{
eval "git branch -D $1";
eval "gb";
}
# git: alias `g` to `git`
# if called with no arguments run `git status`
unalias g
g() {
if [[ $# > 0 ]]; then
git $@
else
git status
fi
}
compdef g=git
# requires "brew install fzf"
alias fbr="fuzzy_branch_search"
function fuzzy_branch_search() {
local branches branch
branches=$(git branch -a) &&
branch=$(echo "$branches" | fzf +s +m -e) &&
git checkout $(echo "$branch" | sed "s:.* remotes/origin/::" | sed "s:.* ::")
}
# simple server
alias serve='python -m SimpleHTTPServer 8000'
alias localhost='open -a "Google Chrome" "http://localhost:8000"'
# Include custom aliases
[[ -f ~/.aliases.local ]] && source ~/.aliases.local
# opam (ocaml package manager) init
alias opamConfig='eval `opam config env`'