Last active
February 19, 2020 02:00
-
-
Save earlonrails/2624352 to your computer and use it in GitHub Desktop.
Revisions
-
earlonrails renamed this gist
Jun 6, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
earlonrails revised this gist
May 15, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -49,7 +49,7 @@ script_builder.call(v_pane_open, arg) end args.each do |arg| script_builder.call(go_left_one_pane) unless size == 2 script_builder.call(h_pane_open, arg) end else -
earlonrails revised this gist
Mar 7, 2013 . 1 changed file with 47 additions and 27 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,38 +2,58 @@ require 'shellwords' args = ARGV size = args.size tab_open = 'tell i term application "System Events" to keystroke "t" using {command down}' v_pane_open = 'tell i term application "System Events" to keystroke "d" using {command down}' h_pane_open = 'tell i term application "System Events" to keystroke "d" using {command down, shift down}' go_left_one_pane = 'tell i term application "System Events" to key code 123 using {command down, option down}' script_builder = Proc.new do |tell, command| command_action = nil pane_action = <<-TEXT tell application "iTerm" activate #{tell} end tell TEXT if command command_action = <<-TEXT tell application "iTerm" activate tell the front terminal activate current session tell the current session write text "#{command}" end tell end tell end tell TEXT end pane_script = Shellwords.escape(pane_action) system("osascript -e #{pane_script}") if command_action command_script = Shellwords.escape(command_action) system("osascript -e #{command_script}") end end # script_builder.call(tab_open, args.shift) # script_builder.call(v_pane_open, args.shift) # script_builder.call(h_pane_open, args.shift) # script_builder.call(go_left_one_pane) # script_builder.call(h_pane_open, args.shift) exit 1 if args.empty? pattern = size % 2 == 0 ? :grid : :lanes script_builder.call(tab_open, args.shift) if ( pattern == :grid ) args.shift((size / 2) -1 ).each do |arg| script_builder.call(v_pane_open, arg) end args.each do |arg| script_builder.call(go_left_one_pane) script_builder.call(h_pane_open, arg) end else args.each do |arg| script_builder.call(v_pane_open, arg) end end -
earlonrails revised this gist
May 7, 2012 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,11 +28,12 @@ if num_args > 1 vertical_panes = num_args / 2 args[1..-1].each_index do |arg_idx| arg = args[arg_idx + 1] if ( pattern == :grid && arg_idx < (vertical_panes - 1 ) ) || pattern == :lanes script_builder.call(v_pane_open, arg) else script_builder.call(go_left_one_pane, arg) script_builder.call(h_pane_open, arg) end end end -
earlonrails created this gist
May 6, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ # splat will make many terminal tabs with selected hosts connecting splat(){ if [[ $TERM_PROGRAM = iTerm.app ]];then ruby ~/Documents/splat.rb "$@" else echo "Must be using iTerm for that function!" fi } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ #!/usr/local/bin/ruby require 'shellwords' args = ARGV num_args = args.size pattern = num_args % 2 == 0 ? :grid : :lanes tab_open = 'tell i term application "System Events" to keystroke "t" using {command down}' v_pane_open = 'tell i term application "System Events" to keystroke "d" using {command down}' h_pane_open = 'tell i term application "System Events" to keystroke "d" using {command down, shift down}' go_left_one_pane = 'tell i term application "System Events" to key code 123 using {command down, option down}' script_builder = Proc.new do |tell, command| script = Shellwords.escape(<<-TEXT tell application "iTerm" activate #{tell} tell the front terminal activate current session tell the current session write text "#{command}" end tell end tell end tell TEXT ) system("osascript -e #{script}") end script_builder.call(tab_open, args[0]) if num_args > 1 vertical_panes = num_args / 2 args[1..-1].each_index do |arg_idx| if ( pattern == :grid && arg_idx < (vertical_panes - 1 ) ) || pattern == :lanes script_builder.call(v_pane_open, args[arg_idx]) else script_builder.call(go_left_one_pane, args[arg_idx]) script_builder.call(h_pane_open, args[arg_idx]) end end end