@@ -5,14 +5,37 @@ echo "use Ctrl-a, k to exit the screen utility"
5
5
port=$( ls /dev/tty.* | grep usb)
6
6
7
7
osascript -e \
8
- " tell application \" iTerm\"
9
- activate
10
- set myterm to (current terminal)
11
- tell myterm
12
- set mysession to (make new session at the end of sessions)
13
- tell mysession
14
- exec command \" /bin/bash -l\"
15
- write text \" screen $port \"
16
- end tell
8
+ " tell application \" Terminal\"
9
+ activate
10
+
11
+ -- search all windows for the arduino-serial tab
12
+ set winlist to every window
13
+ local arduinoTab
14
+ repeat with win in winlist
15
+ set tablist to every tab of win
16
+ repeat with currentTab in tablist
17
+ set title to get custom title of currentTab
18
+ if title is equal to \" arduino-serial\" then
19
+ set arduinoTab to currentTab
20
+ set frontmost of win to true
21
+ end if
22
+ end repeat
23
+ end repeat
24
+
25
+ -- make new tab when arduino-serial does not exist
26
+ try
27
+ arduinoTab
28
+ on error
29
+ tell application \" System Events\"
30
+ set frontmost of application process \" Terminal\" to true
31
+ keystroke \" t\" using command down
17
32
end tell
18
- end tell"
33
+ set currentTabIndex to (get count of tabs of front window)
34
+ set arduinoTab to (tab currentTabIndex of front window)
35
+ set custom title of arduinoTab to \" arduino-serial\"
36
+ end try
37
+
38
+ tell front window
39
+ do script \" screen -S arduino-serial $port \" in arduinoTab
40
+ end tell
41
+ end tell"
0 commit comments