oh-my-posh: Posh-Git autocomplete broken when importing oh-my-posh3 in $profile
Prerequisites
- I have read and understand the
CONTRIBUTINGguide - I looked for duplicate issues before submitting this one
Description
With empty profile:

With imports in profile:

posh-git’s contextual autocomplete is not working if I have these three lines in my $profile:
Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt powerlevel10k_lean
Interestingly, if I remove those and import them at the commandline in that same order, everything works just fine.
Environment
- Oh my Posh version: 3.28.0
- Theme: powerlevel10k_lean (also tried agnoster, same problem)
- Operating System: Windows 10
- Shell: Powershell 7.0.3
- Terminal: Windows Terminal
Steps to Reproduce
- Add these lines to your $profile
Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt powerlevel10k_lean
- navigate to directory containing git repo
cd C:\path\to\git\repo - make a change to a file (or create a new one) to create an unstaged change scenario. for this, calling this file “dir/to/filetoadd.txt”
- type
git add(include a space after “add”) and hit {TAB}
Expected behavior: Terminal autocompletes to: git add dir/to/filetoadd.txt
Actual behavior: Terminal autocompletes to something else, like git add .\.git\
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 3
- Comments: 19 (11 by maintainers)
Commits related to this issue
- fix: set $Global:GitStatus when Get-GitStatus exists resolves #126 — committed to JanDeDobbeleer/oh-my-posh by JanDeDobbeleer 4 years ago
- fix: set $Global:GitStatus when Get-GitStatus exists resolves #126 — committed to JanDeDobbeleer/oh-my-posh by JanDeDobbeleer 4 years ago
- fix: set $Global:GitStatus when Get-GitStatus exists resolves #126 — committed to JanDeDobbeleer/oh-my-posh by JanDeDobbeleer 4 years ago
Ok, sorry for wasting your time. I hadn’t seen this page in the docs and as it was not mentioned in this issue I didn’t think that I had missed any steps.
After setting
$env:POSH_GIT_ENABLED = $truein my$PROFILEthe posh-git completion works as expected.just to note here the problem that I was having since someone might have it as well.
to use posh-git first you need to install it with
Install-Module posh-gitremember to run as admin. After that’s done you can addImport-Module posh-gitto the top of youre $PROFILE, it will look like this:@MendelMonteiro what does
$env:POSH_GIT_ENABLEDsay?can you check the result of
$env:POSH_GIT_ENABLED -eq $true -and (Get-Module -Name "posh-git")andGet-GitStatus? https://github.com/JanDeDobbeleer/oh-my-posh/blob/27d324441be2c35fc905557ece4bdfb1f516273d/src/init/omp.ps1#L48This seems to have regressed in (at least) versions 5.12.1 and 5.16.2.