forked from eddorre/osx-settings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
public.zsh
executable file
·118 lines (104 loc) · 2.42 KB
/
public.zsh
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
# Ruby specific commands
alias rrm='rake routes | mate'
alias 'gem?'='gem list | grep -i $1'
alias run_specs="bundle exec rspec spec/models"
alias run_acceptance="bundle exec rspec spec/acceptance"
alias gi='git'
# Directory/File commands
alias ..='cd ..'
alias ...='cd ../..'
alias home='cd ~/'
alias testlog='tail -f log/test.log'
alias testlogd='tail -f log/test.log | grep DEBUG'
alias devlogd='tail -f log/development.log | grep DEBUG'
alias rr='touch tmp/restart.txt'
alias r='rails'
alias q='exit'
alias be="bundle exec"
# Git specific commands
alias gpo='git push origin'
alias gundo='git reset HEAD'
alias 'branch?'='git branch | grep -i $1'
# Pow commands
alias kapow='powify server restart'
# Functions
function sc() {
if [ -f ./script/rails ]; then
rails c
else
./script/console
fi
}
function ss() {
if [ -f ./script/rails ]; then
rails s
else
./script/server
fi
}
function sgc() {
if [ -f ./script/rails ]; then
rails g controller
else
./script/generate controller $1
fi
}
function sgrc() {
./script/generate rspec_controller $1
}
function sgmi() {
if [ -f ./script/rails ]; then
rails g migration $1
else
./script/generate migration $1
fi
}
function sgm() {
if [ -f ./script/rails ]; then
rails g model $1
else
./script/generate model $1
fi
}
function sgrm() {
./script/generate rspec_model
# TODO: Add Rails 3 specific command
}
function sd() {
./script/destroy
# TODO: Add Rails 3 specific command
}
function migrate() {
if [[ $1 == '' ]]; then
echo 'Migrating Development Database'
rake db:migrate RAILS_ENV=development
echo 'Preparing Test Database'
rake db:test:clone_structure
else
rake db:migrate RAILS_ENV=$1
fi
}
function rollback() {
if [[ $1 == '' ]]; then
echo 'Rolling Back Development Database'
rake db:rollback RAILS_ENV=development
echo 'Preparing Test Database'
rake db:test:clone_structure
else
rake db:rollback RAILS_ENV=$1
fi
}
function switch_user() {
case "$1" in
'eddorre')
git config user.name 'eddorre'
git config user.email 'carlos@eddorre.com'
print 'Setup git project to user eddorre as the username and carlos@eddorre.com as the email address'
;;
'planetargon')
git config user.name 'Carlos Rodriguez'
git config user.email 'carlos@planetargon.com'
print 'Setup git project to user Carlos Rodriguez as the username and carlos@planetargon.com as the email address'
;;
esac
}