Sha256: f3b00445d34afd4eebcb2195a8eed1a9252d38ded53a6deeb49375fff573b566
Contents?: true
Size: 1.68 KB
Versions: 4
Compression:
Stored size: 1.68 KB
Contents
require_relative 'runtime_utils' module Antrapol module ToolRack class TerminalUtilsException < StandardError; end module TerminalUtils def tu_new_terminal(terminal, cmd) cmd = [cmd] if not cmd.is_a?(Array) case terminal when "terminator" `#{terminal} -x "#{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 def tu_possible_terminal avail = [] if RuntimeUtils.on_linux? possible = [ "gnome-terminal","konsole","tilix", "terminator" ] possible.each do |app| avail << app if not File.which(app).nil? end elsif RuntimeUtils.on_windows? avail << "cmd.exe" elsif RuntimeUtils.on_mac? avail << "Terminal" avail << "iTerm2" end avail end # tu_possible_terminal end end end
Version data entries
4 entries across 4 versions & 1 rubygems