Class: Lab42::Tmux

Inherits:
Object show all
Includes:
Command, Commands, Helpers
Defined in:
lib/lab42/tmux.rb,
lib/lab42/tmux/window.rb,
lib/lab42/tmux/command.rb,
lib/lab42/tmux/helpers.rb,
lib/lab42/tmux/version.rb,
lib/lab42/tmux/commands.rb,
lib/lab42/tmux/current_window.rb,
lib/lab42/tmux/window/command.rb,
lib/lab42/tmux/predefined/ruby_session.rb,
lib/lab42/tmux/predefined/tmux_session.rb,
lib/lab42/tmux/window/command/vim_command.rb,
lib/lab42/tmux/predefined/abstract_session.rb

Defined Under Namespace

Modules: Command, Commands, CurrentWindow, Helpers, Predefined Classes: Window

Constant Summary collapse

VERSION =
"0.0.3"

Instance Attribute Summary collapse

Attributes included from Commands

#window_count

Instance Method Summary collapse

Methods included from Helpers

#expand_dir, #if_dir

Methods included from Command

#tmux_increase_current_window_number, #tmux_new_session, #tmux_new_window, #tmux_open_irb, #tmux_open_vim, #tmux_prefixed_command, #tmux_project_home, #tmux_register_window_command, #tmux_send_keys, #tmux_set_window_option, #tmux_set_window_options

Methods included from CurrentWindow

#tmux_current_window, #tmux_current_window_command, #tmux_current_window_designation, #tmux_current_window_number, #tmux_current_window_number=

Methods included from Commands

#lprefix, #tmux, #tmux_source_file

Instance Attribute Details

#commandsObject (readonly)

Returns the value of attribute commands.



17
18
19
# File 'lib/lab42/tmux.rb', line 17

def commands
  @commands
end

#optionsObject (readonly)

Returns the value of attribute options.



17
18
19
# File 'lib/lab42/tmux.rb', line 17

def options
  @options
end

#project_homeObject (readonly)

Returns the value of attribute project_home.



17
18
19
# File 'lib/lab42/tmux.rb', line 17

def project_home
  @project_home
end

#session_nameObject (readonly)

Returns the value of attribute session_name.



17
18
19
# File 'lib/lab42/tmux.rb', line 17

def session_name
  @session_name
end

#windowsObject (readonly)

Returns the value of attribute windows.



17
18
19
# File 'lib/lab42/tmux.rb', line 17

def windows
  @windows
end

Instance Method Details

#add_window(name = nil, options = {}, &blk) ⇒ Object



19
20
21
22
23
24
# File 'lib/lab42/tmux.rb', line 19

def add_window name=nil, options={}, &blk
  window =  Window.new windows.size.succ, self, name: name, command: options[:command]
  windows << window

  window.instance_eval_or_call blk if blk
end

#current_windowObject



26
# File 'lib/lab42/tmux.rb', line 26

def current_window; windows.last end

#current_window?Boolean

Returns:

  • (Boolean)


27
# File 'lib/lab42/tmux.rb', line 27

def current_window?; !!current_window end

#exec!Object



29
30
31
32
33
34
35
# File 'lib/lab42/tmux.rb', line 29

def exec!
  if options.dry_run
    puts render
  else
    exec render
  end
end

#renderObject



37
38
39
# File 'lib/lab42/tmux.rb', line 37

def render
  (commands + final_attach_command).join "\n"
end