-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathrubymotion_run.sh
57 lines (51 loc) · 1.5 KB
/
rubymotion_run.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
#!/bin/sh
TERMINAL_APP="$1"
ACTIVATE_TERMINAL="$2"
PROJECT_DIR="$3"
OPTIONS="$4"
if [ "${PROJECT_DIR}" = "" ]; then
exit 1
fi
if [ "${OPTIONS}" = "" ]; then
RAKE="rake"
else
RAKE="rake ${OPTIONS}"
fi
if type bundle >/dev/null 2>&1; then
if [ -f "Gemfile" ]; then
RAKE="bundle exec ${RAKE}"
fi
fi
if [ "${TERMINAL_APP}" = "iTerm" ]; then
osascript<<END
tell application "iTerm"
if "${ACTIVATE_TERMINAL}" is "true" then activate
select first tab of current window
tell current session of current window
if ("ruby" is in name or "rake" is in name or "repl" is in name) then
write text "exit"
end if
write text "cd '${PROJECT_DIR}'"
write text "${RAKE}"
end tell
end tell
END
else
osascript<<END
tell application "Terminal"
if "${ACTIVATE_TERMINAL}" is "true" then activate
try
set buildWindow to window 1
set selected tab of buildWindow to tab 1 of buildWindow
if (processes in buildWindow) contains "repl" then
do script "exit" in buildWindow
end if
do script "cd '${PROJECT_DIR}'" in buildWindow
on error
do script "alias exit='' && cd '${PROJECT_DIR}' && clear"
delay 0.5
end try
do script "${RAKE}" in front window
end tell
END
fi