Sha256: 79dba9711d4a61ebbc51ccd2413844cc3810d9f20da817c0818482984b682ac7
Contents?: true
Size: 1.32 KB
Versions: 2
Compression:
Stored size: 1.32 KB
Contents
require 'osaka' module Osaka class Terminal < TypicalApplication def initialize super "Terminal" end def tab_configure(options={}) tab_name = options[:name] script = options[:script] directory = options[:directory] control.keystroke('t', :command) if options[:new_tab] if directory != nil control.tell('do script "cd \'' + directory + '\'" in front window') end if tab_name != nil tab_name.gsub!(/[^a-zA-Z0-9 \_\-\.]/, '') # This low-level block is needed because Osaka naively splits # on ';' character, which we need to use mid-script. script_commands = [ 'tell application "Terminal"', 'do script "printf \'\\\\\e]1;' + tab_name.to_s + '\\\\\a\'" in front window', 'end tell' ].map { |c| c.gsub("\"", "\\\"") } escaped_commands = "" script_commands.each { |l| escaped_commands += " -e \"#{l.strip}\"" } new_tab_output = `osascript#{escaped_commands} 2>&1` end control.tell('do script "clear" in front window') if script != nil # LOL, yes, we need to triple-escape for double quotes. # Single quotes should Just Work. control.tell('do script "' + script.gsub("\"", "\\\\\\\"") + '" in front window') end return nil end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
multiterm-0.0.5 | lib/multiterm/terminal.rb |
multiterm-0.0.4 | lib/multiterm/terminal.rb |