Terminal Module Reference
New in version 0.0.1.
Control the macOS Terminal application using JXA-like syntax.
Classes:
|
A class for managing and interacting with Messages.app |
|
A class for managing and interacting with settings sets in Terminal.app. |
|
A wrapper around lists of Terminal settings sets that employs fast enumeration techniques. |
|
A class for managing and interacting with tabs in Terminal.app. |
|
A wrapper around lists of Terminal tabs that employs fast enumeration techniques. |
|
A class for managing and interacting with windows in Terminal.app. |
- class PyXA.apps.Terminal.XATerminalApplication(properties)[source]
Bases:
XASBApplication
,XACanOpenPath
A class for managing and interacting with Messages.app
See also
New in version 0.0.1.
Attributes:
The currently active Terminal tab.
The settings set used for new windows.
Whether Terminal is the active application.
The name of the application.
The settings set used for the window created on application startup.
The version of Terminal.app.
Methods:
do_script
(script[, window_tab, return_result])Executes a Terminal script in the specified window or tab.
settings_sets
([filter])Returns a list of settings sets, as PyXA-wrapped objects, matching the given filter.
- property current_tab: XATerminalTab
The currently active Terminal tab.
- property default_settings: XATerminalSettingsSet
The settings set used for new windows.
- do_script(script: str, window_tab: XATerminalWindow | XATerminalTab | None = None, return_result: bool = False) XATerminalApplication | Dict[str, str] [source]
Executes a Terminal script in the specified window or tab.
If no window or tab is provided, the script will run in a new tab of the frontmost window. If return_result is True, the script will be run in a new tab no regardless of the value of window_tab.
- Parameters:
script (str) – The script to execute.
window_tab (Union[XATerminalWindow, XATerminalTab], optional) – The window or tab to execute the script in, defaults to None
return_result (bool, optional) – Whether to return the result of script execution, defaults to False
- Returns:
A reference to the Terminal application object, or the result of script execution.
- Return type:
Union[XATerminalApplication, Dict[str, str]]
Changed in version 0.0.9: Now optionally returns the script execution result.
New in version 0.0.1.
- property frontmost: bool
Whether Terminal is the active application.
- property name: str
The name of the application.
- settings_sets(filter: dict | None = None) XATerminalSettingsSetList | None [source]
Returns a list of settings sets, as PyXA-wrapped objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned settings sets will have, or None
- Returns:
The list of settings sets
- Return type:
New in version 0.0.7.
- property startup_settings: XATerminalSettingsSet
The settings set used for the window created on application startup.
- property version: str
The version of Terminal.app.
- class PyXA.apps.Terminal.XATerminalSettingsSet(properties)[source]
Bases:
XAObject
,XAClipboardCodable
A class for managing and interacting with settings sets in Terminal.app.
New in version 0.0.1.
Attributes:
The background color for the tab.
The bold text color for the tab.
The processes which will be ignored when checking whether a tab can be closed without showing a prompt.
The cursor color for the tab.
The tab's custom title.
Whether the font used to display the tab's contents is antialiased.
The name of the font used to display the tab's contents.
The size of the font used to display the tab's contents.
The unique identifier of the settings set.
The name of the settings set.
The normal text color for the tab.
The number of columns displayed in the tab.
The number of rows displayed in the tab.
Whether the title contains a custom title.
Whether the title contains the device name.
Whether the title contains the settings set name.
Whether the title contains the shell path.
Whether the title contains the tab's size, in rows and columns.
Methods:
Gets a clipboard-codable representation of the settings set.
- property clean_commands: list[str]
The processes which will be ignored when checking whether a tab can be closed without showing a prompt.
- property custom_title: str
The tab’s custom title.
- property font_antialiasing: bool
Whether the font used to display the tab’s contents is antialiased.
- property font_name: str
The name of the font used to display the tab’s contents.
- property font_size: int
The size of the font used to display the tab’s contents.
- get_clipboard_representation() str [source]
Gets a clipboard-codable representation of the settings set.
When the clipboard content is set to a settings set, the setting set’s name is added to the clipboard.
- Returns:
The setting set’s name
- Return type:
str
New in version 0.0.8.
- property id: int
The unique identifier of the settings set.
- property name: str
The name of the settings set.
- property number_of_columns: int
The number of columns displayed in the tab.
- property number_of_rows: int
The number of rows displayed in the tab.
- property title_displays_custom_title: bool
Whether the title contains a custom title.
- property title_displays_device_name: bool
Whether the title contains the device name.
- property title_displays_settings_name: bool
Whether the title contains the settings set name.
- property title_displays_shell_path: bool
Whether the title contains the shell path.
- property title_displays_window_size: bool
Whether the title contains the tab’s size, in rows and columns.
- class PyXA.apps.Terminal.XATerminalSettingsSetList(properties: dict, filter: dict | None = None)[source]
Bases:
XAList
,XAClipboardCodable
A wrapper around lists of Terminal settings sets that employs fast enumeration techniques.
All properties of settings sets can be called as methods on the wrapped list, returning a list containing each settings set’s value for the property.
New in version 0.0.7.
Methods:
by_background_color
(background_color)by_bold_text_color
(bold_text_color)by_clean_commands
(clean_commands)by_cursor_color
(cursor_color)by_custom_title
(custom_title)by_font_antialiasing
(font_antialiasing)by_font_name
(font_name)by_font_size
(font_size)by_id
(id)by_name
(name)by_normal_text_color
(normal_text_color)by_number_of_columns
(number_of_columns)by_number_of_rows
(number_of_rows)Gets a clipboard-codable representation of each settings set in the list.
id
()name
()- by_background_color(background_color: XAColor) XATerminalSettingsSet | None [source]
- by_bold_text_color(bold_text_color: XAColor) XATerminalSettingsSet | None [source]
- by_clean_commands(clean_commands: list[str]) XATerminalSettingsSet | None [source]
- by_cursor_color(cursor_color: XAColor) XATerminalSettingsSet | None [source]
- by_custom_title(custom_title: str) XATerminalSettingsSet | None [source]
- by_font_antialiasing(font_antialiasing: bool) XATerminalSettingsSet | None [source]
- by_font_name(font_name: str) XATerminalSettingsSet | None [source]
- by_font_size(font_size: int) XATerminalSettingsSet | None [source]
- by_id(id: int) XATerminalSettingsSet | None [source]
- by_name(name: str) XATerminalSettingsSet | None [source]
- by_normal_text_color(normal_text_color: XAColor) XATerminalSettingsSet | None [source]
- by_number_of_columns(number_of_columns: int) XATerminalSettingsSet | None [source]
- by_number_of_rows(number_of_rows: int) XATerminalSettingsSet | None [source]
- by_title_displays_custom_title(title_displays_custom_title: bool) XATerminalSettingsSet | None [source]
- by_title_displays_device_name(title_displays_device_name: bool) XATerminalSettingsSet | None [source]
- by_title_displays_settings_name(title_displays_settings_name: bool) XATerminalSettingsSet | None [source]
- by_title_displays_shell_path(title_displays_shell_path: bool) XATerminalSettingsSet | None [source]
- by_title_displays_window_size(title_displays_window_size: bool) XATerminalSettingsSet | None [source]
- get_clipboard_representation() list[str] [source]
Gets a clipboard-codable representation of each settings set in the list.
When the clipboard content is set to a list of settings sets, each setting set’s name is added to the clipboard.
- Returns:
The list of setting set names
- Return type:
list[str]
New in version 0.0.8.
- class PyXA.apps.Terminal.XATerminalTab(properties)[source]
Bases:
XAObject
,XAClipboardCodable
A class for managing and interacting with tabs in Terminal.app.
New in version 0.0.1.
Attributes:
Whether the tab is currently busy running a process.
The currently visible contents of the tab.
The set of settings which control the tab's behavior and appearance.
The tab's custom title.
The contents of the entire scrolling buffer of the tab.
The number of columns displayed in the tab.
The number of rows displayed in the tab.
The processes currently running in the tab.
Whether the tab is currently selected.
Whether the tab's title contains a custom title.
The tab's TTY device.
Methods:
Gets a clipboard-codable representation of the tab.
- property busy: bool
Whether the tab is currently busy running a process.
- property contents: str
The currently visible contents of the tab.
- property current_settings: XATerminalSettingsSet
The set of settings which control the tab’s behavior and appearance.
- property custom_title: str
The tab’s custom title.
- get_clipboard_representation() list[str] [source]
Gets a clipboard-codable representation of the tab.
When the clipboard content is set to a Terminal tab, the tab’s custom title and its history are added to the clipboard.
- Returns:
The tab’s custom title and history
- Return type:
list[str]
New in version 0.0.8.
- property history: str
The contents of the entire scrolling buffer of the tab.
- property number_of_columns: int
The number of columns displayed in the tab.
- property number_of_rows: int
The number of rows displayed in the tab.
- property processes: list[str]
The processes currently running in the tab.
- property selected: bool
Whether the tab is currently selected.
- property title_displays_custom_title: bool
Whether the tab’s title contains a custom title.
- property tty: str
The tab’s TTY device.
- class PyXA.apps.Terminal.XATerminalTabList(properties: dict, filter: dict | None = None)[source]
Bases:
XAList
,XAClipboardCodable
A wrapper around lists of Terminal tabs that employs fast enumeration techniques.
All properties of tabs can be called as methods on the wrapped list, returning a list containing each tab’s value for the property.
New in version 0.0.7.
Methods:
busy
()by_busy
(busy)by_contents
(contents)by_current_settings
(current_settings)by_custom_title
(custom_title)by_history
(history)by_number_of_columns
(number_of_columns)by_number_of_rows
(number_of_rows)by_processes
(processes)by_selected
(selected)by_tty
(tty)contents
()Gets a clipboard-codable representation of each tab in the list.
history
()selected
()tty
()- by_busy(busy: bool) XATerminalTab | None [source]
- by_contents(contents: str) XATerminalTab | None [source]
- by_current_settings(current_settings: XATerminalSettingsSet) XATerminalTab | None [source]
- by_custom_title(custom_title: str) XATerminalTab | None [source]
- by_history(history: str) XATerminalTab | None [source]
- by_number_of_columns(number_of_columns: int) XATerminalTab | None [source]
- by_number_of_rows(number_of_rows: int) XATerminalTab | None [source]
- by_processes(processes: list[str]) XATerminalTab | None [source]
- by_selected(selected: bool) XATerminalTab | None [source]
- by_title_displays_custom_title(title_displays_custom_title: bool) XATerminalTab | None [source]
- by_tty(tty: str) XATerminalTab | None [source]
- current_settings() XATerminalSettingsSetList [source]
- get_clipboard_representation() list[str] [source]
Gets a clipboard-codable representation of each tab in the list.
When the clipboard content is set to a list of Terminal tabs, each tab’s custom title and history are added to the clipboard.
- Returns:
The list of each tab’s custom title and history
- Return type:
list[str]
New in version 0.0.8.
- class PyXA.apps.Terminal.XATerminalWindow(properties)[source]
Bases:
XASBWindow
,XASBPrintable
,XAObject
A class for managing and interacting with windows in Terminal.app.
New in version 0.0.1.
Attributes:
Whether the window is currently the frontmost Terminal window.
The Terminal tab currently displayed in the window.
Methods:
tabs
([filter])Returns a list of tabs, as PyXA-wrapped objects, matching the given filter.
- property frontmost: bool
Whether the window is currently the frontmost Terminal window.
- property position: tuple[int, int]
- property selected_tab: XATerminalTab
The Terminal tab currently displayed in the window.
- tabs(filter: dict | None = None) XATerminalTabList | None [source]
Returns a list of tabs, as PyXA-wrapped objects, matching the given filter.
- Parameters:
filter (Union[dict, None]) – A dictionary specifying property-value pairs that all returned tabs will have, or None
- Returns:
The list of tabs
- Return type:
New in version 0.0.7.