Variables¶
Provides support for iTerm2 variables, which hold information associated with various objects such as sessions, tabs, and windows.
- class VariableMonitor(connection: iterm2.connection.Connection, scope: iterm2.variables.VariableScopes, name: str, identifier: Optional[str])¶
Watches for changes to a variable.
VariableMonitor is a context manager that helps observe changes in iTerm2 Variables.
- Parameters
connection – The connection to iTerm2.
scope – The scope in which the variable should be evaluated.
name – The variable name.
identifier –
- A tab, window, or session identifier. Must correspond to
the passed-in scope. If the scope is APP this should be None. If the scope is SESSION or WINDOW the identifier may be “all” or “active”.
See also
Example “Per-Host Colors”
Example “Change Color Presets On Theme Change”
Example:
async with iterm2.VariableMonitor( connection, iterm2.VariableScopes.SESSION, "jobName", my_session.session_id) as mon: while True: new_value = await mon.async_get() DoSomething(new_value)
- async async_get() → Any¶
Returns the new value of the variable.
- class VariableScopes(value)¶
Describes the scope in which a variable can be evaluated.
- APP = 4¶
Whole-app scope
- SESSION = 1¶
Session scope
- TAB = 2¶
Tab scope
- WINDOW = 3¶
Window scope