async def async_split_pane(self, vertical=False, before=False, profile=None, profile_customizations=None): """ Splits the pane, creating a new session. :param vertical: Bool. If true, the divider is vertical, else horizontal. :param before: Bool, whether the new session should be left/above the existing one. :param profile: The profile name to use. None for the default profile. :param profile_customizations: A :class:`LocalWriteOnlyProfile` giving changes to make in profile. :returns: New :class:`Session`. :throws: :class:`SplitPaneException` if something goes wrong. """ if profile_customizations is None: custom_dict = None else: custom_dict = profile_customizations.values result = await iterm2.rpc.async_split_pane( self.connection, self.__session_id, vertical, before, profile, profile_customizations=custom_dict) if result.split_pane_response.status == iterm2.api_pb2.SplitPaneResponse.Status.Value("OK"): new_session_id = result.split_pane_response.session_id[0] app = await iterm2.app.async_get_app(self.connection) await app.async_refresh() return app.get_session_by_id(new_session_id) else: raise SplitPaneException( iterm2.api_pb2.SplitPaneResponse.Status.Name(result.split_pane_response.status))
async def async_split_pane(self, vertical=False, before=False, profile=None): """ Splits the pane, creating a new session. :param vertical: Bool. If true, the divider is vertical, else horizontal. :param before: Bool, whether the new session should be left/above the existing one. :param profile: The profile name to use. None for the default profile. :returns: New iterm.session.Session. :throws: SplitPaneException if something goes wrong. """ result = await iterm2.rpc.async_split_pane(self.connection, self.__session_id, vertical, before, profile) if result.split_pane_response.status == iterm2.api_pb2.SplitPaneResponse.Status.Value( "OK"): new_session_id = result.split_pane_response.session_id[0] app = await iterm2.app.async_get_app(self.connection) await app.async_refresh() return app.get_session_by_id(new_session_id) else: raise SplitPaneException( iterm2.api_pb2.SplitPaneResponse.Status.Name( result.split_pane_response.status))
async def async_create_tab(self, profile=None, command=None, index=None): """ Creates a new tab in this window. :param profile: The profile name to use or None for the default profile. :param command: The command to run in the new session, or None for the default for the profile. :param index: The index in the window where the new tab should go (0=first position, etc.) :returns: :class:`Tab` :raises: CreateTabException if something goes wrong. """ result = await iterm2.rpc.async_create_tab(self.connection, profile=profile, window=self.__window_id, index=index, command=command) if result.create_tab_response.status == iterm2.api_pb2.CreateTabResponse.Status.Value( "OK"): session_id = result.create_tab_response.session_id app = await iterm2.app.async_get_app(self.connection) session = app.get_session_by_id(session_id) _window, tab = await app.async_get_tab_and_window_for_session( session) return tab else: raise CreateTabException( iterm2.api_pb2.CreateTabResponse.Status.Name( result.create_tab_response.status))
async def async_create( connection: iterm2.connection.Connection, profile: str = None, command: str = None, profile_customizations: iterm2.profile.LocalWriteOnlyProfile = None ) -> typing.Optional['Window']: """Creates a new window. :param connection: A :class:`~iterm2.connection.Connection`. :param profile: The name of the profile to use for the new window. :param command: A command to run in lieu of the shell in the new session. Mutually exclusive with profile_customizations. :param profile_customizations: LocalWriteOnlyProfile giving changes to make in profile. Mutually exclusive with command. :returns: A new :class:`Window` or `None` if the session ended right away. :throws: `~iterm2.app.CreateWindowException` if something went wrong. .. seealso:: Example ":ref:`create_window_example`" """ if command is not None: p = iterm2.profile.LocalWriteOnlyProfile() p.set_use_custom_command( iterm2.profile.Profile.USE_CUSTOM_COMMAND_ENABLED) p.set_command(command) custom_dict = p.values elif profile_customizations is not None: custom_dict = profile_customizations.values else: custom_dict = None result = await iterm2.rpc.async_create_tab( connection, profile=profile, window=None, profile_customizations=custom_dict) ctr = result.create_tab_response if ctr.status == iterm2.api_pb2.CreateTabResponse.Status.Value("OK"): app = await iterm2.app.async_get_app(connection, False) if not app: return await Window._async_load(connection, ctr.window_id) session = app.get_session_by_id(ctr.session_id) if session is None: return None window, _tab = app.get_tab_and_window_for_session(session) if window is None: return None return window else: raise iterm2.app.CreateWindowException( iterm2.api_pb2.CreateTabResponse.Status.Name( result.create_tab_response.status))
async def async_create_tab( self, profile: typing.Optional[str] = None, command: typing.Optional[str] = None, index: typing.Optional[int] = None, profile_customizations: typing.Optional[ iterm2.profile.LocalWriteOnlyProfile] = None ) -> typing.Optional[iterm2.tab.Tab]: """ Creates a new tab in this window. :param profile: The profile name to use or None for the default profile. :param command: The command to run in the new session, or None for the default for the profile. Mutually exclusive with profile_customizations. :param index: The index in the window where the new tab should go (0=first position, etc.) :param profile_customizations: LocalWriteOnlyProfile giving changes to make in profile. Mutually exclusive with command. :returns: :class:`Tab` or `None` if the session closed right away. :throws: CreateTabException if something goes wrong. """ if command is not None: p = iterm2.profile.LocalWriteOnlyProfile() p.set_use_custom_command( iterm2.profile.Profile.USE_CUSTOM_COMMAND_ENABLED) p.set_command(command) custom_dict = p.values elif profile_customizations is not None: custom_dict = profile_customizations.values else: custom_dict = None result = await iterm2.rpc.async_create_tab( self.connection, profile=profile, window=self.__window_id, index=index, profile_customizations=custom_dict) if result.create_tab_response.status == iterm2.api_pb2.CreateTabResponse.Status.Value( "OK"): session_id = result.create_tab_response.session_id app = await iterm2.app.async_get_app(self.connection) assert (app) session = app.get_session_by_id(session_id) if not session: None _window, tab = app.get_tab_and_window_for_session(session) return tab else: raise CreateTabException( iterm2.api_pb2.CreateTabResponse.Status.Name( result.create_tab_response.status))
async def async_split_pane( self, vertical: bool = False, before: bool = False, profile: typing.Union[None, str] = None, profile_customizations: typing.Union[ None, iterm2.profile.LocalWriteOnlyProfile] = None ) -> 'Session': """ Splits the pane, creating a new session. :param vertical: If `True`, the divider is vertical, else horizontal. :param before: If `True`, the new session will be to the left of or above the session being split. Otherwise, it will be to the right of or below it. :param profile: The profile name to use. `None` for the default profile. :param profile_customizations: Changes to the profile that should affect only this session, or `None` to make no changes. :returns: A newly created Session. :throws: :class:`SplitPaneException` if something goes wrong. .. seealso:: Example ":ref:`broadcast_example`" """ if profile_customizations is None: custom_dict = None else: custom_dict = profile_customizations.values result = await iterm2.rpc.async_split_pane( self.connection, self.__session_id, vertical, before, profile, profile_customizations=custom_dict) if result.split_pane_response.status == iterm2.api_pb2.SplitPaneResponse.Status.Value( "OK"): new_session_id = result.split_pane_response.session_id[0] app = await iterm2.app.async_get_app(self.connection) assert (app) await app.async_refresh() session = app.get_session_by_id(new_session_id) if session: return session raise SplitPaneException( "No such session {}".format(new_session_id)) else: raise SplitPaneException( iterm2.api_pb2.SplitPaneResponse.Status.Name( result.split_pane_response.status))
async def async_create( connection: iterm2.connection.Connection, profile: str=None, command: str=None, profile_customizations: iterm2.profile.LocalWriteOnlyProfile=None) -> typing.Optional['Window']: """Creates a new window. :param connection: A :class:`~iterm2.connection.Connection`. :param profile: The name of the profile to use for the new window. :param command: A command to run in lieu of the shell in the new session. Mutually exclusive with profile_customizations. :param profile_customizations: LocalWriteOnlyProfile giving changes to make in profile. Mutually exclusive with command. :returns: A new :class:`Window` or `None` if the session ended right away. :throws: `~iterm2.app.CreateWindowException` if something went wrong. .. seealso:: Example ":ref:`create_window_example`" """ if command is not None: p = iterm2.profile.LocalWriteOnlyProfile() p.set_use_custom_command(iterm2.profile.Profile.USE_CUSTOM_COMMAND_ENABLED) p.set_command(command) custom_dict = p.values elif profile_customizations is not None: custom_dict = profile_customizations.values else: custom_dict = None result = await iterm2.rpc.async_create_tab( connection, profile=profile, window=None, profile_customizations=custom_dict) ctr = result.create_tab_response if ctr.status == iterm2.api_pb2.CreateTabResponse.Status.Value("OK"): app = await iterm2.app.async_get_app(connection, False) if not app: return await Window._async_load(connection, ctr.window_id) session = app.get_session_by_id(ctr.session_id) if session is None: return None window, _tab = app.get_tab_and_window_for_session(session) if window is None: return None return window else: raise iterm2.app.CreateWindowException( iterm2.api_pb2.CreateTabResponse.Status.Name( result.create_tab_response.status))
async def async_create_tab( self, profile: typing.Optional[str]=None, command: typing.Optional[str]=None, index: typing.Optional[int]=None, profile_customizations: typing.Optional[iterm2.profile.LocalWriteOnlyProfile]=None) -> typing.Optional[iterm2.tab.Tab]: """ Creates a new tab in this window. :param profile: The profile name to use or None for the default profile. :param command: The command to run in the new session, or None for the default for the profile. Mutually exclusive with profile_customizations. :param index: The index in the window where the new tab should go (0=first position, etc.) :param profile_customizations: LocalWriteOnlyProfile giving changes to make in profile. Mutually exclusive with command. :returns: :class:`Tab` or `None` if the session closed right away. :throws: CreateTabException if something goes wrong. """ if command is not None: p = iterm2.profile.LocalWriteOnlyProfile() p.set_use_custom_command(iterm2.profile.Profile.USE_CUSTOM_COMMAND_ENABLED) p.set_command(command) custom_dict = p.values elif profile_customizations is not None: custom_dict = profile_customizations.values else: custom_dict = None result = await iterm2.rpc.async_create_tab( self.connection, profile=profile, window=self.__window_id, index=index, profile_customizations=custom_dict) if result.create_tab_response.status == iterm2.api_pb2.CreateTabResponse.Status.Value("OK"): session_id = result.create_tab_response.session_id app = await iterm2.app.async_get_app(self.connection) assert(app) session = app.get_session_by_id(session_id) if not session: None _window, tab = app.get_tab_and_window_for_session(session) return tab else: raise CreateTabException( iterm2.api_pb2.CreateTabResponse.Status.Name(result.create_tab_response.status))
async def async_split_pane( self, vertical: bool=False, before: bool=False, profile: typing.Union[None, str]=None, profile_customizations: typing.Union[None, iterm2.profile.LocalWriteOnlyProfile]=None) -> 'Session': """ Splits the pane, creating a new session. :param vertical: If `True`, the divider is vertical, else horizontal. :param before: If `True`, the new session will be to the left of or above the session being split. Otherwise, it will be to the right of or below it. :param profile: The profile name to use. `None` for the default profile. :param profile_customizations: Changes to the profile that should affect only this session, or `None` to make no changes. :returns: A newly created Session. :throws: :class:`SplitPaneException` if something goes wrong. .. seealso:: Example ":ref:`broadcast_example`" """ if profile_customizations is None: custom_dict = None else: custom_dict = profile_customizations.values result = await iterm2.rpc.async_split_pane( self.connection, self.__session_id, vertical, before, profile, profile_customizations=custom_dict) if result.split_pane_response.status == iterm2.api_pb2.SplitPaneResponse.Status.Value("OK"): new_session_id = result.split_pane_response.session_id[0] app = await iterm2.app.async_get_app(self.connection) assert(app) await app.async_refresh() session = app.get_session_by_id(new_session_id) if session: return session raise SplitPaneException("No such session {}".format(new_session_id)) else: raise SplitPaneException( iterm2.api_pb2.SplitPaneResponse.Status.Name(result.split_pane_response.status))
async def async_create(connection, profile=None, command=None, profile_customizations=None): """Creates a new window. :param connection: A :class:`iterm2.Connection`. :param profile: The name of the profile to use for the new window. :param command: A command to run in lieu of the shell in the new session. Mutually exclusive with profile_customizations. :param profile_customizations: LocalWriteOnlyProfile giving changes to make in profile. Mutually exclusive with command. :returns: A new :class:`Window`. :throws: CreateWindowException if something went wrong. """ if command is not None: p = profile.LocalWriteOnlyProfile() p.set_use_custom_command( profile.Profile.USE_CUSTOM_COMMAND_ENABLED) p.set_command(command) custom_dict = p.values elif profile_customizations is not None: custom_dict = profile_customizations.values else: custom_dict = None result = await iterm2.rpc.async_create_tab( connection, profile=profile, window=None, profile_customizations=custom_dict) ctr = result.create_tab_response if ctr.status == iterm2.api_pb2.CreateTabResponse.Status.Value("OK"): app = await iterm2.app.async_get_app(connection) session = app.get_session_by_id(ctr.session_id) window, _tab = app.get_tab_and_window_for_session(session) return window else: raise CreateWindowException( iterm2.api_pb2.CreateTabResponse.Status.Name( result.create_tab_response.status))
async def async_create(connection, profile=None, command=None, profile_customizations=None): """Creates a new window. :param connection: A :class:`iterm2.Connection`. :param profile: The name of the profile to use for the new window. :param command: A command to run in lieu of the shell in the new session. Mutually exclusive with profile_customizations. :param profile_customizations: LocalWriteOnlyProfile giving changes to make in profile. Mutually exclusive with command. :returns: A new :class:`Window`. :throws: CreateWindowException if something went wrong. """ if command is not None: p = profile.LocalWriteOnlyProfile() p.set_use_custom_command(profile.Profile.USE_CUSTOM_COMMAND_ENABLED) p.set_command(command) custom_dict = p.values elif profile_customizations is not None: custom_dict = profile_customizations.values else: custom_dict = None result = await iterm2.rpc.async_create_tab( connection, profile=profile, window=None, profile_customizations=custom_dict) ctr = result.create_tab_response if ctr.status == iterm2.api_pb2.CreateTabResponse.Status.Value("OK"): app = await iterm2.app.async_get_app(connection) session = app.get_session_by_id(ctr.session_id) window, _tab = app.get_tab_and_window_for_session(session) return window else: raise CreateWindowException( iterm2.api_pb2.CreateTabResponse.Status.Name( result.create_tab_response.status))