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
|
# File 'lib/toolrack/terminal_utils.rb', line 11
def tu_new_terminal(terminal, cmd)
cmd = [cmd] if not cmd.is_a?(Array)
case terminal
when "terminator", "tilix"
`#{terminal} -e "bash -c '#{cmd.join(" ")}'" &`
when "gnome-terminal"
`#{terminal} -- bash -c "#{cmd.join(" ")}; exec bash"`
when "iTerm2"
`osascript -e \
'tell application "iTerm"
activate
create window with default profile
delay 0.5
set currentWindow to current window
tell current session of currentWindow
write text "#{cmd.join(" ")}"
end tell
end tell'
`
when "Terminal"
`osascript -e \
'tell application "Terminal"
activate
do script "#{cmd.join(" ")}"
end tell'
`
else
raise TerminalUtilsException, "Terminal '#{terminal}' not supported. Supported terminal are : #{tu_possible_terminal.join(", ")}"
end
end
|