Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 273 lines (253 sloc) 7.498 kb
9b1a5e5 Initial commit
Rogelio Samour and Tim Pope authored
1 # ~/.hashrc
2 # vim:set ft=sh sw=2 sts=2:
3
4 [ -e "$HASHROCKET_DIR" ] || HASHROCKET_DIR="$HOME/hashrocket"
5 export HASHROCKET_DIR
6
7 for dir in /opt/local/bin /usr/local/bin "$HOME/bin"; do
2bdee32 Be careful with PATH order
Rogelio J. Samour and Tim Pope authored
8 case "$PATH:" in
9 *:"$dir":*) PATH="`echo "$PATH"|sed -e "s#:$dir##"`" ;;
9b1a5e5 Initial commit
Rogelio Samour and Tim Pope authored
10 esac
2bdee32 Be careful with PATH order
Rogelio J. Samour and Tim Pope authored
11 [ ! -d "$dir" ] || PATH="$dir:$PATH"
9b1a5e5 Initial commit
Rogelio Samour and Tim Pope authored
12 done
13 for dir in /usr/local/sbin /opt/local/sbin; do
14 case ":$PATH:" in
15 *:"$dir":*) ;;
16 *) [ ! -d "$dir" ] || PATH="$PATH:$dir" ;;
17 esac
18 done
19
20 HASHROCKET_AUTHOR_ALOWE="Adam Lowe"
2c238dd Add bernerd. Remove andrew and corey
Josh Graham and Matt Yoho authored
21 HASHROCKET_AUTHOR_BERNERDSCHAEFER="Bernerd Schaefer"
9b1a5e5 Initial commit
Rogelio Samour and Tim Pope authored
22 HASHROCKET_AUTHOR_BIGTIGER="Jim Remsik"
23 HASHROCKET_AUTHOR_DAVEOTT="Dave Ott"
c64c1ec Add Shane and Josh
shaneriley authored
24 HASHROCKET_AUTHOR_DELITESCERE="Josh Graham"
9b1a5e5 Initial commit
Rogelio Samour and Tim Pope authored
25 HASHROCKET_AUTHOR_DESI="Desi McAdam"
26 HASHROCKET_AUTHOR_DURRAN="Durran Jordan"
b3a3942 Add Cameron
Lar Van Der Jagt authored
27 HASHROCKET_AUTHOR_CAMEROND="Cameron Daigle"
9b1a5e5 Initial commit
Rogelio Samour and Tim Pope authored
28 HASHROCKET_AUTHOR_L4RK="Jon Larkowski"
29 HASHROCKET_AUTHOR_LI0N="Mark Smith"
30 HASHROCKET_AUTHOR_LESHILL="Les Hill"
178306c Add Josh to hpair authors
Joshua Davey and Veezus Kreist authored
31 HASHROCKET_AUTHOR_JGDAVEY="Joshua Davey"
7a17011 Add Matthew Conway
Les Hill and Mat Schaffer and Sandro Turriate authored
32 HASHROCKET_AUTHOR_MATTONRAILS="Matthew Conway"
868a6dc Add Matt Sacks
Sandro Turriate authored
33 HASHROCKET_AUTHOR_MATTSACKS="Matt Sacks"
bdd2d61 Add Thais to hpair
Thais Camilo and Tim Pope authored
34 HASHROCKET_AUTHOR_NARWEN="Thais Camilo"
9b1a5e5 Initial commit
Rogelio Samour and Tim Pope authored
35 HASHROCKET_AUTHOR_OBIE="Obie Fernandez"
cf19547 Add Paul to hashrc
Durran Jordan and Obie Fernandez authored
36 HASHROCKET_AUTHOR_PAULELLIOTT="Paul Elliott"
edff8af Add rbxbx to authors
Robert Pitts and Tim Pope authored
37 HASHROCKET_AUTHOR_RBXBX="Robert Pitts"
9b1a5e5 Initial commit
Rogelio Samour and Tim Pope authored
38 HASHROCKET_AUTHOR_SANDRO="Sandro Turriate"
c64c1ec Add Shane and Josh
shaneriley authored
39 HASHROCKET_AUTHOR_SHANERILEY="Shane Riley"
22df7c6 Add Shay to hashrc
Paul Elliott and Shay Arnett authored
40 HASHROCKET_AUTHOR_SHAYARNETT="Shay Arnett"
d33b462 Hire Lar
Lar Van Der Jagt and Tim Pope authored
41 HASHROCKET_AUTHOR_SUPASPOIDA="Lar Van Der Jagt"
2872284 Rogelio J. Samour Ensure proper Ro branding
therubymug authored
42 HASHROCKET_AUTHOR_THERUBYMUG="Rogelio J. Samour"
9b1a5e5 Initial commit
Rogelio Samour and Tim Pope authored
43 HASHROCKET_AUTHOR_TPOPE="Tim Pope"
30b6660 Veezus Kreist Veezus, not Veez
veezus authored
44 HASHROCKET_AUTHOR_VEEZUS="Veezus Kreist"
9b1a5e5 Initial commit
Rogelio Samour and Tim Pope authored
45 HASHROCKET_AUTHOR_VOXDOLO="Stephen Caudill"
46 HASHROCKET_AUTHOR_WGIBBS="Wes Gibbs"
47
48 hcd() {
49 cd "$HASHROCKET_DIR/$1"
50 }
51
52 hpair() {
53 local name email args initials author ret write
54 name=""
55 email="dev"
0c9af45 Tim Pope Slightly less aggressive fix
tpope authored
56 if [ -n "$ZSH_VERSION" ]; then
4199005 Tim Pope Fix weird bash/zsh conflict
tpope authored
57 eval 'args=(${(i)@})'
6a1f2f2 Tim Pope Fix hpair on zsh
tpope authored
58 else
59 args="`for arg in "$@"; do echo "x$arg"|sed -e 's/^x//'|tr ' ' _; done|sort -f`"
60 fi
9b1a5e5 Initial commit
Rogelio Samour and Tim Pope authored
61 for arg in $args; do
62 initials=
63 author=
64 case "x$arg" in
65 x-h)
66 echo 'hpair rocketeer1 rocketeer2'
67 echo 'hpair rocketeer1 gueststar1="Real Name"'
68 echo 'hpair -u # go solo'
69 echo 'hpair # status'
70 return 1
71 ;;
72 x-e) ret=email; continue ;;
73 x-n) ret=name; continue ;;
74 x-f) ret=file; continue ;;
75 x-c) ret=commit; continue ;;
76 x-s) ret=setenv; continue ;;
77 x-u) ret=unsetenv; continue ;;
78 x-w) write=1; continue ;;
31407a0 Tim Pope Fix hpair --help exiting shell
tpope authored
79 x-*) echo "Unknown option $arg" >&2; return 1 ;;
9b1a5e5 Initial commit
Rogelio Samour and Tim Pope authored
80 x*=*)
81 initials="`echo "$arg"|sed -e s/=.*//`"
82 author="`echo "$arg"|sed -e s/[^=]*=//|tr _ ' '`"
83 ;;
84 [^-]*)
85 initials="`echo "$arg"|tr a-z A-Z`"
86 eval "author=\"\$HASHROCKET_AUTHOR_$initials\""
87 ;;
88 esac
89 if [ -z "$author" ]; then
90 echo "Invalid id $arg" >&2
91 return 1
92 fi
93 name="$name and $author"
94 email="$email+`echo "$initials"|tr A-Z a-z`"
95 done
96 name="`echo $name|sed -e 's/^ *and *//'`"
97 email="$email@hashrocket.com"
98 case "$ret" in
99 unsetenv) unset GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL
100 [ ! -n "$write" ] || rm -f "$HOME/.hpairrc"
101 ;;
102 email) echo "$email" ;;
103 name) echo "$name" ;;
104 file) git config user.name "$name" && git config user.email "$email" ;;
105 commit)
106 (
107 if [ "" = "$name" ]; then
108 unset GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL
109 else
110 export GIT_AUTHOR_NAME="$name" GIT_AUTHOR_EMAIL="$email"
111 fi
112 git commit
113 ) ;;
114 *)
115 if [ "" = "$name" ]; then
116 if [ -u "$write" ]; then
5e308b8 Tim Pope Remove hard tabs
tpope authored
117 unset GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL
118 rm -f "$HOME/.hpairrc"
9b1a5e5 Initial commit
Rogelio Samour and Tim Pope authored
119 elif [ -n "$GIT_AUTHOR_NAME" ]; then
5e308b8 Tim Pope Remove hard tabs
tpope authored
120 echo "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>"
9b1a5e5 Initial commit
Rogelio Samour and Tim Pope authored
121 else
5e308b8 Tim Pope Remove hard tabs
tpope authored
122 return 1
9b1a5e5 Initial commit
Rogelio Samour and Tim Pope authored
123 fi
124 else
125 export GIT_AUTHOR_NAME="$name" GIT_AUTHOR_EMAIL="$email"
126 echo "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>"
127 if [ -n "$write" ]; then
8d1ebe9 Tim Pope Add whitespace handling to hpair -w
tpope authored
128 rm -f "$HOME/.hpairrc"
129 printf 'hpair' > "$HOME/.hpairrc"
130 for arg in "$@"; do
131 case "$arg" in
132 -w) ;;
133 *" "*) printf " '$arg'" >> "$HOME/.hpairrc" ;;
134 *) printf " $arg" >> "$HOME/.hpairrc" ;;
135 esac
136 done
137 echo >> "$HOME/.hpairrc"
9b1a5e5 Initial commit
Rogelio Samour and Tim Pope authored
138 fi
139 fi ;;
140 esac
141 }
142 [ -n "$GIT_AUTHOR_EMAIL" -o ! -f "$HOME/.hpairrc" -o -z "$PS1" ] || . "$HOME/.hpairrc"
143
1392fc4 Refresh hpair variables before commit
Pairing Workstation Zapp authored
144 git() {
145 [ -f "$HOME/.hitch_export_authors" ] && . "$HOME/.hitch_export_authors"
146 [ -f "$HOME/.hpairrc" ] && . "$HOME/.hpairrc" >/dev/null
147 command git "$@"
148 }
149
9b1a5e5 Initial commit
Rogelio Samour and Tim Pope authored
150 hclone() {
d77f803 Tim Pope Support more resource specifiers in hclone
tpope authored
151 local url basename
9e83e57 hclone foo.git strips .git from directory name
Sandro Turriate and Tim Pope authored
152 basename="`basename $1 .git`"
d77f803 Tim Pope Support more resource specifiers in hclone
tpope authored
153 if [ ! -d "$HASHROCKET_DIR/$basename" ]; then
154 case "$1" in
838a9fe Tim Pope Fix hclone git@...
tpope authored
155 *:*) url="$1" ;;
156 */*) url="git@github.com:$1.git" ;;
157 *) url="git@github.com:hashrocket/$1.git" ;;
d77f803 Tim Pope Support more resource specifiers in hclone
tpope authored
158 esac
159 git clone "$url" "$HASHROCKET_DIR/$basename" || return 1
160 if [ -f "$HASHROCKET_DIR/$basename/config/database.example.yml" ]; then
1567c19 Tim Pope Set up automatic ctags generation in hclone
tpope authored
161 cp "$HASHROCKET_DIR/$basename/config/database.example.yml" "$HASHROCKET_DIR/$basename/config/database.yml"
9b1a5e5 Initial commit
Rogelio Samour and Tim Pope authored
162 fi
163 fi
d77f803 Tim Pope Support more resource specifiers in hclone
tpope authored
164 hcd "$basename"
1567c19 Tim Pope Set up automatic ctags generation in hclone
tpope authored
165 if [ ! -f ".git/hooks/ctags" ]; then
166 echo '#!/bin/sh' > .git/hooks/ctags
8693452 Tim Pope Fix automatic ctags from git hooks
tpope authored
167 echo 'ctags --tag-relative -f .git/tags --exclude=.git --languages=-javascript,sql -R' >> .git/hooks/ctags
1567c19 Tim Pope Set up automatic ctags generation in hclone
tpope authored
168 chmod +x .git/hooks/ctags
169 for basename in post-checkout post-commit post-merge; do
170 echo '#!/bin/sh' > .git/hooks/$basename
171 echo '$GIT_DIR/hooks/ctags >/dev/null 2>&1 &' >> .git/hooks/$basename
172 chmod +x .git/hooks/$basename
173 done
174 .git/hooks/ctags
175 fi
9b1a5e5 Initial commit
Rogelio Samour and Tim Pope authored
176 }
177
178 # Tab completion
179 if [ -n "$BASH_VERSION" ]; then
180 _hcd()
181 {
182 local cur projects
183
184 [ -r "$HASHROCKET_DIR" ] || return 0
185
785c62a Tim Pope Support Debian unstable version of ZSH
tpope authored
186 eval 'COMPREPLY=()'
9b1a5e5 Initial commit
Rogelio Samour and Tim Pope authored
187 cur=${COMP_WORDS[COMP_CWORD]}
188 projects=$(\ls "$HASHROCKET_DIR")
189
190 if [ $COMP_CWORD -eq 1 ]; then
785c62a Tim Pope Support Debian unstable version of ZSH
tpope authored
191 eval 'COMPREPLY=( $(compgen -o filenames -W "$projects" $cur) )'
9b1a5e5 Initial commit
Rogelio Samour and Tim Pope authored
192 fi
193
194 return 0
195 }
196 complete -F _hcd hcd
197 elif [ -n "$ZSH_VERSION" ]; then
198 #compdef '_files -W "$HASHROCKET_DIR"' hcd
199 compctl -/ -W "$HASHROCKET_DIR" hcd
200 fi
201
202 rails_root() {
203 (
204 dir=${1:-$(pwd)}
205 i=0
206 while [ "/" != "$dir" -a "$i" -ne 16 ]; do
207 if [ -f "$dir/config/environment.rb" ]; then
208 echo "$dir"
209 return 0
210 fi
211 dir="$(dirname "$dir")"
212 i=$(expr $i + 1)
213 done
214 return 1
215 )
216 }
217
218 stc() {
219 (
220 local root
221 root="`rails_root`"
222 [ -n "$root" ] || root=.
223 if [ "$root/config/amazon_s3.yml" -nt "$root/tmp/s3cfg" ] || [ -f "$root/config/amazon_s3.yml" -a ! -f "$root/tmp/s3cfg" ]; then
224 ruby -ryaml -e '
225 c = YAML.load(File.read(ARGV.first))[ENV["RAILS_ENV"]||"development"]
226 File.open(ARGV.last,"w") do |f|
227 f.puts "access_key = #{c["access_key_id"]}"
228 f.puts "secret_key = #{c["secret_access_key"]}"
229 end if c.kind_of?(Hash)
230 ' "$root/config/amazon_s3.yml" "$root/tmp/s3cfg"
231 fi
232 if [ -f "$root/tmp/s3cfg" ]; then
233 exec s3cmd -c "$root/tmp/s3cfg" "$@"
234 else
235 exec s3cmd "$@"
236 fi
237 )
238 }
239
f93050e Tim Pope Support Rails 3 in script aliases
tpope authored
240 script_rails() {
241 if [ -f "`rails_root`/script/rails" ]; then
242 "`rails_root`/script/rails" "$@"
243 else
244 local name
245 name="$1"
246 shift
247 "`rails_root`/script/$name" "$@"
248 fi
249 }
250
d75d30a Add twiki
Stephen Caudill authored
251 twiki () {
252 rake db:migrate && rake db:migrate:redo && rake db:test:prepare
253 }
254
f93050e Tim Pope Support Rails 3 in script aliases
tpope authored
255 alias sc='script_rails console'
256 alias ss='script_rails server -u'
257 alias sdbc='script_rails dbconsole -p'
9b1a5e5 Initial commit
Rogelio Samour and Tim Pope authored
258
259 alias ll='ls -l'
260
261 alias gb='git branch'
262 alias gc='git commit -v'
263 alias gca='git commit -a -v'
264 alias gco="git checkout"
265 alias gd='git diff'
266 alias gdc='git diff --cached'
267 alias gdh='git diff HEAD'
268 alias gp='git push'
269 alias gl='git pull'
270 alias gpr='git pull --rebase'
271 alias gst='git status'
178f8d5 Add gap for 'git add -p'
Paul Elliott authored
272 alias gap='git add -p'
Something went wrong with that request. Please try again.