startShellProfile method

Future<GhosttyTerminalShellLaunch?> startShellProfile({
  1. required GhosttyTerminalShellProfile profile,
  2. Map<String, String>? platformEnvironment,
  3. Map<String, String> environmentOverrides = const <String, String>{'TERM' : 'xterm-256color'},
})

Starts one of the shared shell profiles and returns the resolved launch.

Returns null when no launch candidate was available or every candidate failed to start.

Implementation

Future<GhosttyTerminalShellLaunch?> startShellProfile({
  required GhosttyTerminalShellProfile profile,
  Map<String, String>? platformEnvironment,
  Map<String, String> environmentOverrides = const <String, String>{
    'TERM': 'xterm-256color',
  },
}) async {
  Object? lastError;
  for (final launch in ghosttyTerminalShellLaunches(
    profile: profile,
    platformEnvironment: platformEnvironment,
    environmentOverrides: environmentOverrides,
  )) {
    try {
      await startLaunch(launch);
      return activeShellLaunch;
    } catch (error) {
      lastError = error;
      await stop();
    }
  }

  if (lastError != null) {
    appendDebugOutput('[shell profile failed: $lastError]\n');
  }
  return null;
}