Oraide provides a set of conveniences around tmux’s send-keys command. For more information about how tmux actually works, please see tmux’s man page.
Send keys to a tmux session. This function is a wrapper around tmux’s send-keys command.
If literal is False, tmux will attempt to convert keynames such as Escape or Space to their single-key equivalents.
Parameters: |
|
---|
A session to which to send keys. This function allows for the deduplication of session names when repeatedly sending keystrokes the same session.
Parameters: |
|
---|
Return a context manager that disables prompts before sending keystrokes to the session. For example:
session.enter('vim some_file.txt') # prompt first
with session.auto_advance(): # disables prompts
session.teletype('jjji')
session.enter('Hello, World!', after=keys.escape)
session.enter(':x') # prompt first
Type keys, then press Enter.
By default, typing character-by-character is enabled with the teletype parameter.
Note
If auto-advancing is disabled, then a confirmation prompt appears before keystrokes are sent to the session.
Parameters: |
|
---|
Send each literal character in keys to the session.
Parameters: |
|
---|
See also
Type keys character-by-character, as if you were actually typing them by hand.
The delay parameter adds time between each keystroke for verisimilitude. The actual time between keystrokes varies up to ten percent more or less than the nominal value. The default, 90 milliseconds, approximates a fast typist.
Note
If auto-advancing is disabled, then a confirmation prompt appears before keystrokes are sent to the session.
Parameters: |
|
---|
If tmux’s send-keys command ends with an error status code, an exception is raised.
The command sent to tmux returned a non-zero exit status. This is an unrecognized tmux error.
This exception type inherits from subprocess.CalledProcessError, which adds returncode, cmd, and output attributes.
Bases: oraide.TmuxError
The tmux server connection failed (often because the server was not running at the time the command was sent).
Bases: oraide.TmuxError
The tmux session was not found (but a connection to tmux server was established).
This exception type adds another attribute, session, for your debugging convenience.
This module provides shortcuts for sending special keystrokes to tmux sessions. The functions and constants are typically used with oraide.Session.send_keys(), or the after parameter on certain oraide.Session methods.
The constants of this module are provided as a Pythonic substitute for the strings used in tmux’s keyname lookup table. For example, to send a backspace key, the string 'BSpace' may be replaced with a reference to oraide.keys.backspace. The following keys are provided:
as well as the function keys f1 through f20.
Make a string that tmux will parse as the alt key (Alt) and key pressed at the same time.
Note
The key parameter is case-sensitive. If key is uppercase, it’s equivalent to entering Shift and the key.
>>> from oraide.keys import alt
>>> alt('a') # alt + a
'A-a'
>>> alt('A') # alt + shift + a
'A-A'
Make a string that tmux will parse as the command key (also known as the meta, super, cmd, Apple, and Windows key) and key pressed at the same time.
Note
The key parameter is case-sensitive. If key is uppercase, it’s equivalent to entering Shift and the key.
>>> from oraide.keys import command
>>> command('a') # command + a
'M-a'
>>> command('A') # command + shift + a
'M-A'
Make a string that tmux will parse as the control key (Ctrl) and key pressed at the same time.
Note
The key parameter is case-sensitive. If key is uppercase, it’s equivalent to entering Shift and the key.
>>> from oraide.keys import control
>>> control('a') # ctrl + a
'C-a'
>>> control('A') # ctrl + shift + a
'C-A'