Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'CHEF-1932'

  • Loading branch information...
commit c89cbd0cdb2d215e1838eaf9aae435a525adab9d 2 parents 1ea161d + bab8352
@danielsdeleo danielsdeleo authored
Showing with 14 additions and 4 deletions.
  1. +14 −4 chef/lib/chef/knife/ssh.rb
View
18 chef/lib/chef/knife/ssh.rb
@@ -245,16 +245,26 @@ def tmux
end
def macterm
- require 'appscript'
+ begin
+ require 'appscript'
+ rescue LoadError
+ STDERR.puts "you need the rb-appscript gem to use knife ssh macterm. `(sudo) gem install rb-appscript` to install"
+ raise
+ end
+
Appscript.app("/Applications/Utilities/Terminal.app").windows.first.activate
Appscript.app("System Events").application_processes["Terminal.app"].keystroke("n", :using=>:command_down)
term = Appscript.app('Terminal')
window = term.windows.first.get
- session.servers_for.each do |server|
+
+ (session.servers_for.size - 1).times do |i|
+ window.activate
Appscript.app("System Events").application_processes["Terminal.app"].keystroke("t", :using=>:command_down)
+ end
+
+ session.servers_for.each_with_index do |server, tab_number|
cmd = "unset PROMPT_COMMAND; echo -e \"\\033]0;#{server.host}\\007\"; ssh #{server.user ? "#{server.user}@#{server.host}" : server.host}"
- Appscript.app('Terminal').do_script(cmd, :in => window.tabs.last.get)
- sleep 1
+ Appscript.app('Terminal').do_script(cmd, :in => window.tabs[tab_number + 1].get)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.