MCPcopy Index your code
hub / github.com/google-gemini/gemini-cli / getShellConfiguration

Function getShellConfiguration

packages/core/src/utils/shell-utils.ts:658–699  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

656 * @returns The ShellConfiguration for the current environment.
657 */
658export function getShellConfiguration(): ShellConfiguration {
659 if (isWindows()) {
660 // -NonInteractive prevents PSReadLine from intercepting console input
661 // events inside the ConPTY session, which otherwise causes interactive
662 // TUI tools (e.g. pnpm create vite, vim) to receive malformed key events
663 // and exit when arrow keys are pressed.
664 const powershellArgsPrefix = ['-NoProfile', '-NonInteractive', '-Command'];
665 const comSpec = process.env['ComSpec'];
666 if (comSpec) {
667 const executable = comSpec.toLowerCase();
668 if (
669 executable.endsWith('powershell.exe') ||
670 executable.endsWith('pwsh.exe')
671 ) {
672 return {
673 executable: comSpec,
674 argsPrefix: powershellArgsPrefix,
675 shell: 'powershell',
676 };
677 }
678 }
679
680 const pwshPath = resolveExecutable('pwsh.exe');
681 if (pwshPath) {
682 return {
683 executable: pwshPath,
684 argsPrefix: ['-NoProfile', '-Command'],
685 shell: 'powershell',
686 };
687 }
688
689 // Fall back to Windows PowerShell 5.1 when pwsh.exe is not installed.
690 return {
691 executable: 'powershell.exe',
692 argsPrefix: powershellArgsPrefix,
693 shell: 'powershell',
694 };
695 }
696
697 // Unix-like systems (Linux, macOS)
698 return { executable: 'bash', argsPrefix: ['-c'], shell: 'bash' };
699}
700
701/**
702 * Export the platform detection constant for use in process management (e.g., killing processes).

Callers 10

parseCommandDetailsFunction · 0.85
hasRedirectionFunction · 0.85
prepareExecutionMethod · 0.85
executeCommandHookMethod · 0.85
resolveAuthValueFunction · 0.85
processStringMethod · 0.85

Calls 2

isWindowsFunction · 0.85
resolveExecutableFunction · 0.85

Tested by 1