Configure Copilot CLI on Windows to stop using Powershell (only use git bash)? #189318
Replies: 7 comments 3 replies
|
Hi, This behavior happens because on Windows many CLI tools (including Copilot CLI) detect PowerShell as the default shell, even if the command is launched from Git Bash. In practice, the tool often falls back to If you want Copilot CLI to consistently run commands using Git Bash, there are a few approaches that usually work. 1. Run Copilot CLI explicitly inside Git BashMake sure Copilot is installed in the same environment and start it from a Git Bash session: copilotIf the CLI internally spawns commands, you can explicitly invoke them through bash: bash -lc "<command>"2. Ensure Git Bash is the active shellSome tools rely on environment variables to determine the shell. In Git Bash you can verify: echo $SHELLIt should return something like: /usr/bin/bashIf not, you can force it in your profile ( export SHELL=/usr/bin/bash3. Use Windows Terminal with Git Bash as defaultIf you are using Windows Terminal, set Git Bash as the default profile: https://learn.microsoft.com/windows/terminal/customize-settings/profile-general This helps prevent tools from defaulting to PowerShell when launching new shell sessions. 4. (Optional) Force commands through bashIf Copilot generates commands that default to PowerShell syntax, you can pipe them to bash explicitly: copilot suggest | bashNotesCurrently there is no official Copilot CLI configuration option to globally force a specific shell on Windows, so behavior depends on how the CLI detects the runtime environment. If GitHub adds a configuration flag in the future (for example something like |
|
Open your ~/.bashrc file in Git Bash: |
|
Set the In Git Bash, run this to set it for the current session: export SHELL="C:/Program Files/Git/bin/bash.exe"
copilotFor a permanent fix, add that The exact path can vary. In Git Bash, run After setting, verify in Git Bash with |
|
I tried all the solutions above. None of them worked. I am on windows 11 and using GitHub Copilot CLI 1.0.35. Below is the related output from copilot: Let me use the standard PowerShell instead:Let me try with explicit mode and check available sessions:Let me try a simpler approach:It appears PowerShell 6+ (pwsh) is not installed on this system. Let me check what's available and view the file first:Now let me try running the commands using bash/cmd through a different approach. Let me check what shell environments are available by trying a direct command without the powershell wrapper:I apologize for the difficulty. The PowerShell tool requires PowerShell 6+ (pwsh) which is not installed on this system. Any recommendations? |
Uh oh!
There was an error while loading. Please reload this page.
Select Topic Area
Question
Body
I want to use copilot cli on my windows 11 computer. By default, I am using git bash as terminal.
Even when starting copilot cli within a git bash, it keeps executing power shell commands instead of bash commands, and I didn't find a way to change this behaviour.
How can i configure copilot cli to only use git bash?
All reactions