Class: Tmux::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/tmux/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, device) ⇒ Client

Returns a new instance of Client.



7
8
9
# File 'lib/tmux/client.rb', line 7

def initialize(server, device)
  @server, @device = server, device
end

Instance Attribute Details

#current_panePane (readonly)

Returns The currently displayed pane.

Returns:

  • (Pane)

    The currently displayed pane.

Required tmux version:

  • >=1.2



136
137
138
# File 'lib/tmux/client.rb', line 136

def current_pane
  @current_pane
end

#current_windowWindow (readonly)

Returns The currently displayed window.

Returns:

Required tmux version:

  • >=1.2



125
126
127
# File 'lib/tmux/client.rb', line 125

def current_window
  @current_window
end

#deviceString (readonly)

Returns:

  • (String)


6
7
8
# File 'lib/tmux/client.rb', line 6

def device
  @device
end

#heightInteger (readonly)

Returns:

  • (Integer)


41
42
43
# File 'lib/tmux/client.rb', line 41

def height
  @height
end

#identifierString (readonly)

Returns:

  • (String)


12
13
14
# File 'lib/tmux/client.rb', line 12

def identifier
  @identifier
end

#messagesArray<String> (readonly)

Returns A log of messages.

Returns:

  • (Array<String>)

    A log of messages

tmux command:

  • show-messages

Required tmux version:

  • >=1.2



104
105
106
# File 'lib/tmux/client.rb', line 104

def messages
  @messages
end

#serverServer (readonly)

Returns:



4
5
6
# File 'lib/tmux/client.rb', line 4

def server
  @server
end

#sessionSession

Setting this will make a client switch to another session.

Returns:

tmux command:

  • switch-client



22
23
24
# File 'lib/tmux/client.rb', line 22

def session
  @session
end

#termString (readonly)

$TERM of a client.

Returns:

  • (String)


50
51
52
# File 'lib/tmux/client.rb', line 50

def term
  @term
end

#utf8Boolean (readonly) Also known as: utf8?

True if the terminal is using UTF-8.

Returns:

  • (Boolean)


59
60
61
# File 'lib/tmux/client.rb', line 59

def utf8
  @utf8
end

#widthInteger (readonly)

Returns:

  • (Integer)


34
35
36
# File 'lib/tmux/client.rb', line 34

def width
  @width
end

Instance Method Details

#command_prompt(template, prompts = [])

TODO:

escape prompts and template

This method returns an undefined value.

Opens a command prompt in the client. This may be used to execute commands interactively.

Parameters:

  • template (String)

    The template is used as the command to execute. Before the command is executed, the first occurrence of the string '%%' and all occurrences of '%1' are replaced by the response to the first prompt, the second '%%' and all '%2' are replaced with the response to the second prompt, and so on for further prompts. Up to nine prompt responses may be replaced ('%1' to '%9')

  • prompts (Array<String>) (defaults to: [])

    prompts is a list of prompts which are displayed in order; otherwise a single prompt is displayed, constructed from template

tmux command:

  • command-prompt



184
185
186
187
188
189
190
191
# File 'lib/tmux/client.rb', line 184

def command_prompt(template, prompts = [])
  prompts = prompts.join(",")
  flags = []
  flags << "-p #{prompts}" unless prompts.empty?
  flags << "-t #{identifier}"
  flags << "\"#{template}\""
  @server.invoke_command "command-prompt #{flags.join(" ")}"
end

#detach

This method returns an undefined value.

Detaches a client from tmux.

tmux command:

  • detach-client



70
71
72
# File 'lib/tmux/client.rb', line 70

def detach
  @server.invoke_command "detach-client -t #@device"
end

#display_panes

This method returns an undefined value.

Displays a visible indicator of each pane shown by a client.

tmux command:

  • display-panes

Required tmux version:

  • >=1.0



117
118
119
120
121
# File 'lib/tmux/client.rb', line 117

def display_panes
  @server.check_for_version!("1.0")

  @server.invoke_command("display-panes -t #@device")
end

#lock

This method returns an undefined value.

Locks a client.

tmux command:

  • lock-client

Required tmux version:

  • >=1.1



79
80
81
82
83
# File 'lib/tmux/client.rb', line 79

def lock
  @server.check_for_version!("1.1")

  @server.invoke_command "lock-client -t #@device"
end

#message(text)

This method returns an undefined value.

Displays a message.

Parameters:

  • text (String)

    The message to display

tmux command:

  • display-message

Required tmux version:

  • >=1.0



152
153
154
155
156
# File 'lib/tmux/client.rb', line 152

def message(text)
  @server.check_for_version!("1.0")

  @server.invoke_command "display-message -t #@device \"#{text}\""
end

#refresh

This method returns an undefined value.

Refreshs a client.

tmux command:

  • refresh-client



97
98
99
# File 'lib/tmux/client.rb', line 97

def refresh
  @server.invoke_command "refresh-client -t #@device"
end

#select_interactively

This method returns an undefined value.

Opens a prompt inside a client allowing a window index to be entered interactively.

tmux command:

  • command-prompt + select-window



162
163
164
# File 'lib/tmux/client.rb', line 162

def select_interactively
  command_prompt "select-window -t:%%", ["index"]
end

#suspend

This method returns an undefined value.

Suspends a client.

tmux command:

  • suspend-client



89
90
91
# File 'lib/tmux/client.rb', line 89

def suspend
  @server.invoke_command "suspend-client -c #@device"
end