![]() ![]() Service_2 = await open_pane_and_start_service ( window, "~/GitHub/service_2", "make start-dev", "compiled successfully in", pane_to_split = service_1, vertical = True ) # Service 3 Service_1 = await open_pane_and_start_service ( window, "~/GitHub/service_1", "make start-dev", "Watching for changes.", vertical = False, ) # Service 2 current_terminal_window if window is not None : # Service 1 async_get_app ( connection ) window = app. create_task ( run_fs ()) await f_task return pane async def main ( connection ): app = await iterm2. IGNORECASE ) is not None print ( "Found string, service is started." ) return pane loop = asyncio. search ( pattern = string_to_detect_to_finish, string = stringified_string_contents, flags = re. string if len ( stringified_string_contents ) > 0 : finished = re. number_of_lines_above_screen ): stringified_string_contents = stringified_string_contents screen_output. async_get () for line_no in range ( screen_output. get_screen_streamer () as streamer : while not finished : stringified_string_contents = "" screen_output = await streamer. async_send_text ( command ' \n ' ) finished = False async with pane. async_send_text ( 'cd ' fs_path ' \n ' ) await pane. async_activate () async def run_fs (): await pane. async_split_pane ( vertical ) await pane. current_session pane = session if pane_to_split is not None : pane = await session. Import asyncio import re import iterm2 async def open_pane_and_start_service ( window, fs_path, command, string_to_detect_to_finish, pane_to_split = None, vertical = False, ): tab = window. Which sometimes can take 10 minutes to perform a full file synchronization first thing in the morning. Personally, I use this with multiple mutagen sessions, Wait for a certain line to appear on the screen (typically Listening at.Provide an optional pane_to_split value to specify a previous pane to split from.Play with Vertical=True or Vertical=False to achieve the layout you need.Open a new pane at a folder that you specify.Script visible in the list of iTerm scripts What it does, in detail The script will then appear in the list of available scripts: py extension in the iTerm2 scripts folder. I separated the logic into a neat open_pane_and_start_service function that you can call multiple times for starting up all the services you need. Each one will wait for a completion message before opening the next pane. Here is my example script for starting multiple services in iTerm2, each on their On a laptop, sometimes there is not enough CPU power to boot up everything simultaneously. This rules out port clash problems, synchronisation conflicts, etc. I needed to actually wait for each server to print its “ready/listening” messageīefore moving on to the next one. Unfortunately, most examples I found on the web using the iTerm2 PythonĪPI started everything in parallel. There are awesome process monitors like PM2 to help manage multiple services, butįully-dockerized workflows and place them in separate panes for easy log monitoring. ![]()
0 Comments
Leave a Reply. |