Module: Tmux

Defined in:
lib/tmux.rb,
lib/tmux/pane.rb,
lib/tmux/server.rb,
lib/tmux/widget.rb,
lib/tmux/client.rb,
lib/tmux/window.rb,
lib/tmux/buffer.rb,
lib/tmux/version.rb,
lib/tmux/session.rb,
lib/tmux/options.rb,
lib/tmux/status_bar.rb,
lib/tmux/options_list.rb,
lib/tmux/window/status.rb,
lib/tmux/options/option.rb,
lib/tmux/filterable_hash.rb,
lib/tmux/status_bar/field.rb,
lib/tmux/exception/in_tmux.rb,
lib/tmux/options/attr_option.rb,
lib/tmux/window/status/state.rb,
lib/tmux/options/color_option.rb,
lib/tmux/widgets/progress_bar.rb,
lib/tmux/options/number_option.rb,
lib/tmux/options/string_option.rb,
lib/tmux/options/keymap_option.rb,
lib/tmux/options/symbol_option.rb,
lib/tmux/options/boolean_option.rb,
lib/tmux/exception/index_in_use.rb,
lib/tmux/exception/basic_exception.rb,
lib/tmux/options/word_array_option.rb,
lib/tmux/exception/unknown_command.rb,
lib/tmux/options/char_array_option.rb,
lib/tmux/options/bell_action_option.rb,
lib/tmux/options/justification_option.rb,
lib/tmux/exception/unsupported_version.rb,
lib/tmux/options/clock_mode_style_option.rb

Defined Under Namespace

Modules: Exception, FilterableHash, Options, Widgets Classes: Buffer, Client, OptionsList, Pane, Server, Session, StatusBar, Widget, Window

Constant Summary

TMUX_VERSION =

The newest version of tmux we officially support

"1.3".freeze
VERSION =

The version of this library

"0.0.2".freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.binaryString

Path of the tmux binary.

Returns:

  • (String)


27
28
29
# File 'lib/tmux.rb', line 27

def binary
  @binary
end

.verboseBoolean Also known as: verbose?

Print verbose information on $stderr?

Returns:

  • (Boolean)


31
32
33
# File 'lib/tmux.rb', line 31

def verbose
  @verbose
end

Class Method Details

.invoke_command(cmd, unset_tmux = false) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Invokes a tmux command and returns all output.

Parameters:

  • cmd (String)

    Command to invoke

  • unset_tmux (Boolean) (defaults to: false)

    If true, unsets $TMUX before calling tmux, to allow nesting

Returns:

  • (String)

    all output

Raises:



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/tmux.rb', line 42

def invoke_command(cmd, unset_tmux = false)
  command = ""
  command << "TMUX='' " if unset_tmux
  command << "#{@binary} #{cmd}"

  $stderr.puts(command) if verbose?
  ret = `#{command} 2>&1`
  if ret.start_with?("unknown command:")
    raise Exception::UnknownCommand, ret.split(":", 2).last.strip
  else
    return ret
  end
end