module Lab42::Tmux::Session::Commands
Public Instance Methods
goto(dest)
click to toggle source
# File lib/lab42/tmux/session/commands.rb, line 7 def goto dest return unless dest send_keys "cd #{dest}" end
new_window(window_name, &block)
click to toggle source
# File lib/lab42/tmux/session/commands.rb, line 11 def new_window window_name, &block @window_number += 1 command 'new-window', '-t', session_name, '-n', "'#{window_name}'" goto configuration.project_home instance_exec( &@after_new_window_hook ) if @after_new_window_hook instance_exec( &block ) if block end
really_wait_for( match_rgx, in_pane:, dependent_actions: )
click to toggle source
# File lib/lab42/tmux/session/commands.rb, line 38 def really_wait_for( match_rgx, in_pane:, dependent_actions: ) loop do text = capture_pane in_pane if match_rgx === text conditional_sleep configuration.post_wait_interval return instance_exec( &dependent_actions ) end sleep configuration.wait_interval end end
send_keys(*keys)
click to toggle source
# File lib/lab42/tmux/session/commands.rb, line 19 def send_keys *keys command( 'send-keys', '-t', [session_name, window_number].join(':'), *keys.map(&:inspect), 'C-m' ) end
send_keys_raw(*keys)
click to toggle source
# File lib/lab42/tmux/session/commands.rb, line 23 def send_keys_raw *keys command( 'send-keys', '-t', [session_name, window_number].join(':'), *keys.map(&:inspect) ) end
wait_for(text_or_rgx, alternate_pane_addr=nil, &blk)
click to toggle source
# File lib/lab42/tmux/session/commands.rb, line 27 def wait_for text_or_rgx, alternate_pane_addr=nil, &blk require 'timeout' pane_addr = alternate_pane_addr || window_address text_or_rgx = %r{#{text_or_rgx}}m unless Regexp === text_or_rgx conditional_sleep configuration.pre_wait_interval Timeout.timeout configuration.wait_timeout do really_wait_for text_or_rgx, in_pane: pane_addr, dependent_actions: blk end rescue Timeout::Error end
Private Instance Methods
capture_pane(pane_addr)
click to toggle source
# File lib/lab42/tmux/session/commands.rb, line 50 def capture_pane pane_addr command( 'capture-pane', *(pane_addr.split), '-p' ).tap do |result | p result if $DEBUG end end
conditional_sleep(sleepy_or_falsy)
click to toggle source
# File lib/lab42/tmux/session/commands.rb, line 55 def conditional_sleep sleepy_or_falsy sleep sleepy_or_falsy if sleepy_or_falsy end