code: def launch_in_current_terminal(
      commands_to_launch,
  ) -> Union[
      worker_manager.WorkerManager, worker_manager_v2.WorkerManager
  ]:
      """Launch commands given as CommandToLaunch all in the same terminal.
  
      Args:
        commands_to_launch: An iterable of `CommandToLaunch` namedtuples.
  
      Returns:
        Worker manager that can be used to wait for a program execution to finish.
      """
      if lp_flags.LP_WORKER_MANAGER_V2.value:
          manager = worker_manager_v2.WorkerManager(
              handle_sigterm=True, kill_all_upon_sigint=True
          )
      else:
          manager = worker_manager.WorkerManager()
      atexit.register(manager.wait)
      decorate_output = os.path.dirname(__file__) + "/decorate_output"
  
      for i, command_to_launch in enumerate(commands_to_launch):
          colour = _COLOUR_PALETTE[i % len(_COLOUR_PALETTE)]
  
          env = {}
          env.update(os.environ)
          env.update(command_to_launch.env_overrides)
          process = subprocess.Popen(
              (
                  [
                      decorate_output,
                      str(colour),
                      command_to_launch.title,
                  ]
                  + command_to_launch.command_as_list
              ),
              env=env,
          )
          manager.register_existing_process(
              command_to_launch.title, process.pid
          )
      return manager
  
file_path: launchpad/launchpad/launch/run_locally/launch_local_current_terminal.py
imports: import atexit
  import os
  import subprocess
  from typing import Union
  from launchpad import flags
  from launchpad.launch import worker_manager
  from launchpad.launch import worker_manager_v2
label_desc: Use image node_id 1 for calling a global function with example usage: launch_in_current_terminal(commands_to_launch) and returns: manager