forked from tmuxinator/tmuxinator
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
344aa66
commit c96d04d
Showing
4 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
tell application "iTerm" | ||
activate | ||
|
||
set myterm to (make new terminal) | ||
|
||
set the name of the first window to "<%= @project_name %>" | ||
|
||
tell myterm | ||
set number of columns to 100 | ||
set number of rows to 50 | ||
|
||
-- set up tabs and panes | ||
<% @tabs.each_with_index do |tab, i| %> | ||
<% session = "session#{i}" %> | ||
|
||
-- tab "<%= tab.name %>" | ||
set <%= session %> to (launch session "<%= tab.name %>") | ||
|
||
tell <%= session %> | ||
<% if tab.command %> | ||
write text "<%= tab.command %>" | ||
<% elsif tab.panes %> | ||
-- tmux select-layout -t <%= window(i+1) %> <%=s tab.layout %> | ||
write text "<%= tab.panes.shift %>" | ||
<% tab.panes.each do |pane| %> | ||
tell application "System Events" to keystroke "d" using command down | ||
write text "<%= pane %>" | ||
<% end %> | ||
<% end %> | ||
end tell | ||
<% end %> | ||
|
||
<% if @pre %> | ||
set pre_session to (launch session "pre") | ||
tell pre_session | ||
-- run the pre stuff | ||
write text "<%= @pre.kind_of?(Array) ? @pre.join(" && ") : @pre %>" | ||
end tell | ||
terminate pre_session | ||
<% end %> | ||
|
||
end tell | ||
|
||
-- select window 1 | ||
select the first session of myterm | ||
end tell |
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
module Tmuxinator | ||
|
||
class ITermConfigWriter < ConfigWriter | ||
attr_accessor :file_name, :file_path, :project_name, :project_root, :rvm, :tabs, :pre | ||
|
||
include Tmuxinator::Helper | ||
|
||
def self.write_aliases(aliases) | ||
File.open("#{ENV["HOME"]}/.tmuxinator/scripts/tmuxinator", 'w') {|f| f.write(aliases.join("\n")) } | ||
end | ||
|
||
def initialize(this_full_path=nil) | ||
self.file_path = this_full_path if this_full_path | ||
end | ||
|
||
def file_path= full_path | ||
@file_path = full_path | ||
@file_name = File.basename full_path, '.yml' | ||
process_config! if full_path && File.exist?(full_path) | ||
end | ||
|
||
def write! | ||
raise "Unable to write with out a file_name defined" unless file_name | ||
erb = ERB.new(IO.read(ITERM_TEMPLATE)).result(binding) | ||
tmp = File.open(config_path, 'w') {|f| f.write(erb) } | ||
|
||
"alias start_#{file_name}='$SHELL #{config_path}'" | ||
end | ||
|
||
def config_path | ||
"#{root_dir}#{file_name}.AppleScript" if file_name | ||
end | ||
|
||
private | ||
|
||
def write_alias(stuff) | ||
File.open("#{root_dir}scripts/#{@filename}", 'w') {|f| f.write(stuff) } | ||
end | ||
|
||
def send_keys(cmd, window_number) | ||
return '' unless cmd | ||
"tmux send-keys -t #{window(window_number)} #{s cmd} C-m" | ||
return <<-APPLESCRIPT | ||
tell item <%= window_number %> of | ||
%Q{tell application "System Events" to keystroke "#{cmd}"} | ||
APPLESCRIPT | ||
end | ||
end | ||
end |