class Automux::Core::Tmux::Session
Attributes
base_index[R]
data[R]
Public Class Methods
new(blueprint_data)
click to toggle source
# File lib/automux/core/tmux/session.rb, line 13 def initialize(blueprint_data) @windows = [] @hooks = [] @options = [] @base_index = 0 @data = Data.new(blueprint_data) end
Public Instance Methods
attach_session()
click to toggle source
# File lib/automux/core/tmux/session.rb, line 85 def attach_session %[#{ tmux_with_flags } attach-session -t #{ name }] end
link_window(source_session_name, source_window_identifier, index = nil)
click to toggle source
Links window from source session to current session. Window
name or index must be provided.
E.g.: link_window
(primary, finch, 3)
-
links a window named finch from an existing session named primary as 3rd window in current session.
# File lib/automux/core/tmux/session.rb, line 81 def link_window(source_session_name, source_window_identifier, index = nil) %[tmux link-window -s #{ source_session_name }:#{ source_window_identifier } -t #{ name }:#{ index }] end
move_first_window_or_create_new(window)
click to toggle source
The first window is created alongwith new-session and thus needs to be moved to its correct index.
# File lib/automux/core/tmux/session.rb, line 51 def move_first_window_or_create_new(window) if window == windows.first move_window(window.index) else new_window(window) end end
move_window(index)
click to toggle source
# File lib/automux/core/tmux/session.rb, line 63 def move_window(index) %[tmux move-window -t #{ name }:#{ index }] end
new_session()
click to toggle source
# File lib/automux/core/tmux/session.rb, line 38 def new_session %[#{ tmux_with_flags } new-session -d -s #{ name }] end
new_window(window)
click to toggle source
# File lib/automux/core/tmux/session.rb, line 46 def new_window(window) %[tmux new-window -t #{ name }:#{ window.index }] end
rename_window(window, window_name = window.name)
click to toggle source
# File lib/automux/core/tmux/session.rb, line 59 def rename_window(window, window_name = window.name) %[tmux rename-window -t #{ name }:#{ window.index } #{ window_name }] end
select_layout(window)
click to toggle source
# File lib/automux/core/tmux/session.rb, line 89 def select_layout(window) %[tmux select-layout -t #{ name }:#{ window.index } #{ window.layout }] end
select_window(identifier)
click to toggle source
# File lib/automux/core/tmux/session.rb, line 72 def select_window(identifier) window = get_window(identifier) %[tmux select-window -t #{ name }:#{ window.index }] end
send_keys(identifier, command)
click to toggle source
# File lib/automux/core/tmux/session.rb, line 67 def send_keys(identifier, command) window = get_window(identifier) %[tmux send-keys -t #{ name }:#{ window.index } "#{ command }" C-m] end
set_option(option)
click to toggle source
# File lib/automux/core/tmux/session.rb, line 42 def set_option(option) %[tmux set-option #{ option.name } '#{ option.value }'] end
split_window()
click to toggle source
# File lib/automux/core/tmux/session.rb, line 93 def split_window %[tmux split-window] end
start_server()
click to toggle source
# File lib/automux/core/tmux/session.rb, line 34 def start_server %[tmux start-server] end
window_indexes()
click to toggle source
# File lib/automux/core/tmux/session.rb, line 97 def window_indexes @windows.map(&:index).compact end