forked from hashrocket/dotmatrix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.sharedrc
More file actions
203 lines (179 loc) · 4.74 KB
/
.sharedrc
File metadata and controls
203 lines (179 loc) · 4.74 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
# vim:set ft=sh sw=2 sts=2:
[ -e "$HASHROCKET_DIR" ] || HASHROCKET_DIR="$HOME/hashrocket"
export HASHROCKET_DIR
# Paths for prepending
for dir in /usr/local/bin "$HOME/bin" .git/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
hcd() {
cd "$HASHROCKET_DIR/$1"
if [ -e .git/safe -a ! -L .git/bin ]; then
ln -s ../bin .git
fi
}
git() {
if command -v hub >/dev/null; then
command hub "$@"
else
command git "$@"
fi
}
hitch() {
command hitch "$@"
if [[ -s "$HOME/.hitch_export_authors" ]] ; then source "$HOME/.hitch_export_authors" ; fi
}
alias unhitch='hitch -u'
# Tab completion
if [ -n "$BASH_VERSION" ]; then
_hcd()
{
local cur projects
[ -r "$HASHROCKET_DIR" ] || return 0
eval 'COMPREPLY=()'
cur=${COMP_WORDS[COMP_CWORD]}
projects=$(\ls "$HASHROCKET_DIR")
if [ $COMP_CWORD -eq 1 ]; then
eval 'COMPREPLY=( $(compgen -o filenames -W "$projects" $cur) )'
fi
return 0
}
complete -F _hcd hcd hclone
elif [ -n "$ZSH_VERSION" ]; then
compctl -/ -S '' -W "$HASHROCKET_DIR" hcd
fi
__rails_root() {
(
dir=${1:-$(pwd)}
i=0
while [ "/" != "$dir" -a "$i" -ne 16 ]; do
if [ -f "$dir/config/environment.rb" ]; then
echo "$dir"
return 0
fi
dir="$(dirname "$dir")"
i=$(expr $i + 1)
done
return 1
)
}
script_rails() {
echo "DEPRECATION: script_rails is for Rails 2.3 and earlier. You have bigger problems than getting into a Rails console." >&2
local root="`__rails_root`"
if [ -f "$root/script/rails" ]; then
"$root/script/rails" "$@"
elif [ -f "$root/bin/rails" -a -f "$root/config/application.rb" ]; then
"$root/bin/rails" "$@"
else
local name
name="$1"
shift
"$root/script/$name" "$@"
fi
}
twiki () {
rake db:migrate && rake db:migrate:redo && rake db:test:prepare
}
alias sc='rails console'
alias ss='rails server'
alias sdbc='rails dbconsole -p'
alias ll='ls -l'
# 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
}
gco () {
if [[ $1 == '.' ]]; then
git add -A
git commit -m "CHECKING OUT CURRENT DIRECTORY" -q
git reset HEAD^ -q
git checkout .
else
git checkout "$@"
fi
}
gcr() {
git checkout -b $1 origin/$1
}
alias gap='git add -p'
alias gnap='git add -N . && git add -p'
alias glp='git log -p'
alias glg='git log --graph --oneline --decorate --color --all'
alias gb='git branch'
alias gc='git commit -v'
alias gca='git commit -a -v'
alias gcl='git clean -f -d'
alias gd='git diff'
alias gdc='git diff --cached'
alias gdh='git diff HEAD'
alias gl='git pull'
alias glod='git log --oneline --decorate'
alias gp='git push'
alias gpr='git pull --rebase'
alias gst='git status'
alias gr='git rebase'
alias grc='git rebase --continue'
alias gra='git rebase --abort'
alias reset-authors='git commit --amend --reset-author -C HEAD'
alias vi='vim'
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