-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_in_terminal
More file actions
executable file
·43 lines (35 loc) · 1.28 KB
/
run_in_terminal
File metadata and controls
executable file
·43 lines (35 loc) · 1.28 KB
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
#!/usr/bin/osascript
on run argv
-- Check if command provided
if (count of argv) < 1 then
error "Usage: ./run_in_terminal \"command\" [window-title] [profile]"
end if
-- Parse arguments
set commandToRun to item 1 of argv
set windowTitle to ""
set profileName to ""
if (count of argv) ≥ 2 then
set windowTitle to item 2 of argv
end if
if (count of argv) ≥ 3 then
set profileName to item 3 of argv
end if
-- Open Terminal and run command
tell application "Terminal"
-- Pick random profile if none specified
if profileName is "" then
set allProfiles to name of every settings set
set randomIndex to random number from 1 to count of allProfiles
set profileName to item randomIndex of allProfiles
end if
-- Create new window with profile and run command
set newWindow to do script commandToRun in window 1 of (make new window with properties {current settings:settings set profileName})
-- Set custom title if provided
if windowTitle is not "" then
tell newWindow
set custom title to windowTitle
end tell
end if
activate
end tell
end run