From 9db8fd284bf1ecd9b1068bf2f8a1b93b7148da34 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 6 Jul 2025 23:30:41 +0100 Subject: [PATCH] Fix shell configuration files not being loaded - Ensure bash, zsh, and fish spawn as login shells to read config files - Add -i and -l flags for bash/zsh, --interactive and --login for fish - Avoid duplicate flags if already present - Add user feedback when starting shells in login mode Fixes #251 --- web/src/server/pty/process-utils.ts | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/web/src/server/pty/process-utils.ts b/web/src/server/pty/process-utils.ts index 61ea3746..df875c6a 100644 --- a/web/src/server/pty/process-utils.ts +++ b/web/src/server/pty/process-utils.ts @@ -269,12 +269,31 @@ export function resolveCommand(command: string[]): { // Check if this is an interactive shell command if (isInteractiveShellCommand(cmdName, cmdArgs)) { - logger.debug(`Command '${cmdName}' is an interactive shell, adding -i and -l flags`); - // Add both -i (interactive) and -l (login) flags for proper shell initialization + logger.log(chalk.cyan(`✓ Starting ${cmdName} as login shell to load configuration files`)); + // Add both -i (interactive) and -l/--login flags for proper shell initialization // This ensures shell RC files are sourced and the environment is properly set up + + // Don't add flags if they're already present + const hasInteractiveFlag = cmdArgs.some((arg) => arg === '-i' || arg === '--interactive'); + const hasLoginFlag = cmdArgs.some((arg) => arg === '-l' || arg === '--login'); + + // Build args array + const finalArgs = [...cmdArgs]; + + // For fish shell, use --login and --interactive instead of -l and -i + const isFish = cmdName === 'fish' || cmdName.endsWith('/fish'); + + if (!hasInteractiveFlag) { + finalArgs.unshift(isFish ? '--interactive' : '-i'); + } + + if (!hasLoginFlag) { + finalArgs.unshift(isFish ? '--login' : '-l'); + } + return { command: cmdName, - args: ['-i', '-l', ...cmdArgs], + args: finalArgs, useShell: false, resolvedFrom: 'path', originalCommand: cmdName,