forked from Montana/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmixtape.sh
62 lines (50 loc) · 974 Bytes
/
mixtape.sh
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
#!/bin/bash
dir_is_railsroot() {
checkdir=$1
match_counter=0
for entry in $checkdir/*; do
if [ -d "$entry" ]; then
dir=`basename "$entry"`
for rails_entry in "${RAILS_ENTRIES[@]}"; do
if [ $dir = $rails_entry ]; then
match_counter=$(expr $match_counter + 1)
fi
done
fi
done
if [ $match_counter -lt ${#RAILS_ENTRIES[@]} ]; then
return 1
else
return 0
fi
}
DIR=`pwd`
while [ "$DIR" != "/" ]; do
dir_is_railsroot "$DIR"
if [ "$?" -eq "0" ]; then
cd "$DIR"
fi
DIR=`dirname $DIR`
done
case $1 in
'')
;;
'models') cd 'app/models'
;;
'controllers') cd 'app/controllers'
;;
'helpers') cd 'app/helpers'
;;
'views') cd 'app/views'
;;
'layouts') cd 'app/views/layouts'
;;
'migrate') cd 'db/migrate'
;;
'gems') cd 'vendor/gems'
;;
'plugins') cd 'vendor/plugins'
;;
*) cd "$1"
esac
return 0