How to use the iterm2.rpc.async_invoke_method function in iterm2

To help you get started, we’ve selected a few iterm2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gnachman / iTerm2 / api / library / python / iterm2 / iterm2 / tab.py View on Github external
async def async_set_title(self, title: str):
        """Changes the tab's title.

        This is equivalent to editing the tab's title with the menu item Edit
        Tab Title. The title is an interpolated string.

        :param title: The new title. Set it to an empty string to use the
            default value (the current session's title).

        :throws: :class:`~iterm2.rpc.RPCException` if something goes wrong.
        """
        invocation = iterm2.util.invocation_string(
            "iterm2.set_title",
            {"title": title})
        await iterm2.rpc.async_invoke_method(
            self.connection, self.tab_id, invocation, -1)
github gnachman / iTerm2 / api / library / python / iterm2 / iterm2 / tab.py View on Github external
:param direction: Specifies the direction to move. For example, LEFT
            will cause the pane to the left of the currently active one.
        :returns: The ID of the newly selected session ID, or None if there was
            no session in that direction.

        :throws: :class:`~iterm2.rpc.RPCException` if something goes wrong.
        """
        if not iterm2.capabilities.supports_select_pane_in_direction(
                self.connection):
            raise iterm2.capabilities.AppVersionTooOld()

        invocation = iterm2.util.invocation_string(
            "iterm2.select_pane_in_direction",
            {"direction": direction.value})
        return await iterm2.rpc.async_invoke_method(
            self.connection, self.tab_id, invocation, -1)
github gnachman / iTerm2 / api / library / python / iterm2 / iterm2 / window.py View on Github external
"""Changes the window's title.

        This is equivalent to editing the window's title with the menu item
        Edit Window Title. The title is an interpolated string. Note that when
        using tmux integration, tab titles correspond to tmux window titles.
        iTerm2's window titles have no equivalent in tmux.

        :param title: The new title. Set it to an empty string to use the
            default value (the current tab's title).

        :throws: :class:`~iterm2.rpc.RPCException` if something goes wrong.
        """
        invocation = iterm2.util.invocation_string(
            "iterm2.set_title",
            {"title": title})
        await iterm2.rpc.async_invoke_method(
            self.connection, self.window_id, invocation, -1)
github gnachman / iTerm2 / api / library / python / iterm2 / iterm2 / statusbar.py View on Github external
:param count: The number to show, or 0 to remove it.
        :raises: AppVersionTooOld if not supported by this version of iTerm2.
        """
        if not iterm2.capabilities.supports_status_bar_unread_count(
                self.__connection):
            raise iterm2.capabilities.AppVersionTooOld(
                ("Unread count in status bar components is not " +
                 "supported in this version of iTerm2. Please upgrade " +
                 "to use this script."))

        invocation = iterm2.util.invocation_string(
            "iterm2.set_status_bar_component_unread_count",
            {"identifier": self.__identifier,
             "count": count})
        if session_id:
            await iterm2.rpc.async_invoke_method(
                self.__connection, session_id, invocation, -1)
        else:
            assert self.__connection
            await iterm2.async_invoke_function(self.__connection, invocation)
github gnachman / iTerm2 / api / library / python / iterm2 / iterm2 / session.py View on Github external
self, command: str, timeout: float = -1) -> str:
        """Invoke a tmux command and return its result. Raises an exception if
        this session is not a tmux integration session.

        :param command: The tmux command to run.
        :param timeout: The amount of time to wait for a response, or -1 to use
            the default.

        :returns: The output from tmux.

        :throws: :class:`~iterm2.rpc.RPCException` if something goes wrong.
        """
        invocation = iterm2.util.invocation_string(
            "iterm2.run_tmux_command",
            {"command": command})
        return await iterm2.rpc.async_invoke_method(
            self.connection, self.session_id, invocation, timeout)
github gnachman / iTerm2 / api / library / python / iterm2 / iterm2 / session.py View on Github external
async def async_run_coprocess(self, command_line: str) -> bool:
        """
        Runs a coprocess, provided non is already running.

        :param command_line: The command line for the new coprocess.

        :returns: True if it was launched or False if one was already running.
        """
        iterm2.capabilities.check_supports_coprocesses(self.connection)
        invocation = iterm2.util.invocation_string(
            "iterm2.run_coprocess",
            {"commandLine": command_line})
        return bool(
            await iterm2.rpc.async_invoke_method(
                self.connection, self.session_id, invocation, -1))