Class: Appear::Tmux
- Inherits:
-
Service
- Object
- BaseService
- Service
- Appear::Tmux
- Defined in:
- lib/appear/tmux.rb
Overview
The Tmux service is in charge of interacting with ‘tmux` processes. It is used by the Tmux revealer, but could also be used as the building block for other tmux-related scripts.
see the man page for tmux if you are curious about what clients, windows, panes, and sessions are in Tmux world.
Defined Under Namespace
Classes: Client, Pane, Session, TmuxValue, Window
Instance Method Summary collapse
-
#attach_session_command(session) ⇒ Appear::Util::CommandBuilder
Construct a command that will attach the given session when run.
-
#clients ⇒ Array<Client>
List all the tmux clients on the system.
-
#initialize(svcs = {}) ⇒ Tmux
constructor
A new instance of Tmux.
-
#new_session(opts = {}) ⇒ Object
Create a new session.
-
#new_window(opts = {}) ⇒ Object
Create a new window.
-
#panes ⇒ Array<Pane>
List all the tmux panes on the system.
-
#reveal_pane(pane) ⇒ Object
Reveal a pane in tmux.
-
#send_keys(pane, keys, opts = {}) ⇒ Object
Send keys to a pane.
-
#sessions ⇒ Array<Session>
List all the tmux sessions on the system.
-
#split_window(opts = {}) ⇒ Object
Split a window.
-
#windows ⇒ Array<Window>
List all the tmux windows in any session on the system.
Methods inherited from BaseService
delegate, require_service, required_services
Constructor Details
Instance Method Details
#attach_session_command(session) ⇒ Appear::Util::CommandBuilder
Construct a command that will attach the given session when run
287 288 289 |
# File 'lib/appear/tmux.rb', line 287 def attach_session_command(session) command('attach-session').flags(:t => session) end |
#clients ⇒ Array<Client>
List all the tmux clients on the system
228 229 230 |
# File 'lib/appear/tmux.rb', line 228 def clients ipc_returning(command('list-clients'), Client) end |
#new_session(opts = {}) ⇒ Object
Create a new session
274 275 276 |
# File 'lib/appear/tmux.rb', line 274 def new_session(opts = {}) ipc_returning_one(command('new-session').flags(opts), Session) end |
#new_window(opts = {}) ⇒ Object
Create a new window
264 265 266 |
# File 'lib/appear/tmux.rb', line 264 def new_window(opts = {}) ipc_returning_one(command('new-window').flags(opts), Window) end |
#panes ⇒ Array<Pane>
List all the tmux panes on the system
235 236 237 |
# File 'lib/appear/tmux.rb', line 235 def panes ipc_returning(command('list-panes').flags(:a => true), Pane) end |
#reveal_pane(pane) ⇒ Object
Reveal a pane in tmux.
256 257 258 259 260 261 |
# File 'lib/appear/tmux.rb', line 256 def reveal_pane(pane) ipc(command('select-pane').flags(:t => pane.target)) # TODO: how do we use a real target for this? ipc(command('select-window').flags(:t => "#{pane.session}:#{pane.window}")) pane end |
#send_keys(pane, keys, opts = {}) ⇒ Object
Send keys to a pane
279 280 281 |
# File 'lib/appear/tmux.rb', line 279 def send_keys(pane, keys, opts = {}) ipc(command('send-keys').flags(opts.merge(:t => pane.target)).args(*keys)) end |
#sessions ⇒ Array<Session>
List all the tmux sessions on the system
242 243 244 |
# File 'lib/appear/tmux.rb', line 242 def sessions ipc_returning(command('list-sessions'), Session) end |
#split_window(opts = {}) ⇒ Object
Split a window
269 270 271 |
# File 'lib/appear/tmux.rb', line 269 def split_window(opts = {}) ipc_returning_one(command('split-window').flags(opts), Pane) end |