forked from hashrocket/dotmatrix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.sharedrc
198 lines (177 loc) · 4.85 KB
/
.sharedrc
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
# vim:set ft=sh sw=2 sts=2:
[ -e "$SOURCE_DIR" ] || SOURCE_DIR="$HOME/hashrocket"
export SOURCE_DIR
# DEPRECATED: Use more generic SOURCE_DIR. HASHROCKET_DIR persists as a
# legacy artifact, and for 3rd-party scripts.
export HASHROCKET_DIR=$SOURCE_DIR
# Paths for prepending
#
for dir in /usr/local/bin "$HOME/bin" .git/safe/../../bin; do
case "$PATH:" in
*:"$dir":*) PATH="`echo "$PATH"|sed -e "s#:$dir##"`" ;;
esac
case "$dir" in
/*) [ ! -d "$dir" ] || PATH="$dir:$PATH" ;;
*) PATH="$dir:$PATH" ;;
esac
done
# Paths for appending
#
for dir in /usr/local/sbin /opt/local/sbin /usr/X11/bin; do
case ":$PATH:" in
*:"$dir":*) ;;
*) [ ! -d "$dir" ] || PATH="$PATH:$dir" ;;
esac
done
# Ruby/Rails specific aliases
#
alias be='bundle exec'
alias groutes='rake routes | grep $@'
alias rerun-cucumber="tmux showb | grep cucumber | awk '{print \$2}' | xargs cucumber"
alias rerun-rspec="tmux showb | grep rspec | awk '{print \$2}' | xargs rspec"
alias sc='rails console'
alias scs='rails console --sandbox'
alias sdbc='rails dbconsole -p'
alias ss='rails server'
# Ruby/Rails functions
#
twiki () {
rake db:migrate && rake db:migrate:redo && rake db:test:prepare
}
# File management aliases
#
alias ..='cd ..'
alias cd..='cd ..'
alias l="ls -F -G -lah"
alias la="ls -a"
alias ll='ls -l'
alias lsd='ls -ld *(-/DN)'
alias md='mkdir -p'
alias rd='rmdir'
# File management functions
#
l.() {
ls -ld "${1:-$PWD}"/.[^.]*
}
# Git functions
#
if command -v hub >/dev/null; then
git() {
command hub "$@"
}
fi
# git_prompt_info accepts 0 or 1 arguments (i.e., format string)
# returns text to add to bash PS1 prompt (includes branch name)
git_prompt_info () {
local g="$(command git rev-parse --git-dir 2>/dev/null)"
if [ -n "$g" ]; then
local r
local b
local d
local s
# Rebasing
if [ -d "$g/rebase-apply" ] ; then
if test -f "$g/rebase-apply/rebasing" ; then
r="|REBASE"
fi
b="$(command git symbolic-ref HEAD 2>/dev/null)"
# Interactive rebase
elif [ -f "$g/rebase-merge/interactive" ] ; then
r="|REBASE-i"
b="$(cat "$g/rebase-merge/head-name")"
# Merging
elif [ -f "$g/MERGE_HEAD" ] ; then
r="|MERGING"
b="$(command git symbolic-ref HEAD 2>/dev/null)"
else
if [ -f "$g/BISECT_LOG" ] ; then
r="|BISECTING"
fi
if ! b="$(command git symbolic-ref HEAD 2>/dev/null)" ; then
if ! b="$(command git describe --exact-match HEAD 2>/dev/null)" ; then
b="$(cut -c1-7 "$g/HEAD")..."
fi
fi
fi
# Dirty Branch
local newfile='?? '
if [ -n "$ZSH_VERSION" ]; then
newfile='\?\? '
fi
d=''
s=$(command git status --porcelain 2> /dev/null)
[[ $s =~ "$newfile" ]] && d+='+'
[[ $s =~ "M " ]] && d+='*'
[[ $s =~ "D " ]] && d+='-'
printf "${1-"(%s) "}" "${b##refs/heads/}$r$d"
fi
}
gcr() {
git checkout -b $1 origin/$1
}
# git reset empty files
gref() {
command git --no-pager diff --cached --stat | command grep "|\s*0$" | awk '{system("command git reset " $1)}'
}
# git fix up commits
gfix() {
if (($# < 1)); then
log_error "Usage:\n";
echo " gfix <git-sha>";
return 0;
fi
git_sha=$1;
git cat-file -t "${git_sha}"
if [[ $? -eq 0 ]]; then
git commit --fixup ${git_sha} && git stash && git rebase -i --autosquash ${git_sha}~1 && git stash pop
else
log_error "Invalid git commit sha: '${git_sha}'";
fi
}
# Git aliases
#
alias gap='git add -p'
alias gb='git branch'
alias gc='git commit -v'
alias gca='git commit -a -v'
alias gcl='git clean -f -d'
alias gco='git checkout'
alias gd='git diff'
alias gdc='git diff --cached'
alias gdh='git diff HEAD'
alias gl='git pull'
alias glg='git log --graph --oneline --decorate --color --all'
alias glod='git log --oneline --decorate'
alias glp='git log -p'
alias gnap='git add -N --ignore-removal . && gap && gref'
alias gp='git push'
alias gplease='git push --force-with-lease'
alias gpr='git pull --rebase'
alias gr='git rebase'
alias gra='git rebase --abort'
alias grc='git rebase --continue'
alias grim='git rebase -i master'
alias gst='git status'
alias reset-authors='git commit --amend --reset-author -C HEAD'
# Docker aliases
#
alias dcu="docker-compose up"
alias dcud="docker-compose up -d"
alias dcd="docker-compose down"
alias dcs="docker-compose stop"
alias dcp="docker-compose ps"
alias dcl="docker-compose logs -f"
alias dcr="docker-compose run"
alias dce="docker-compose exec"
# Aliases
#
alias vi='vim'
alias grim='git rebase -i master'
alias grid='git rebase -i develop'
if [ "$(uname)" = Darwin -a "$(command -v vim)" = /usr/bin/vim ]; then
bettervim="/Applications/MacVim.app/Contents/MacOS/Vim"
[ -f "$bettervim" ] && alias vim="$bettervim"
[ -f "$HOME$bettervim" ] && alias vim="$HOME$bettervim"
fi
# RVM exectuble path for scripting, when available
if [[ -s "$HOME/.rvm/bin" ]] ; then export PATH="$PATH:$HOME/.rvm/bin" ; fi