Fix: Auto-enable fancy shell mode when Oh My Posh is detected#6488
Merged
Fix: Auto-enable fancy shell mode when Oh My Posh is detected#6488
Conversation
Oh My Posh interferes with the VIRTUAL_ENV environment variable when using pipenv's default pexpect-based shell activation (compat mode). The activate script sets VIRTUAL_ENV inside the spawned shell, but Oh My Posh hooks into shell initialization and overrides it. The --fancy flag works because it sets VIRTUAL_ENV before spawning the shell, so Oh My Posh sees it from the start. This fix automatically enables fancy mode when Oh My Posh is detected (via the POSH_THEME environment variable), similar to how Windows and pwsh already force fancy mode. Fixes #6226
007adc4 to
4c027af
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #6226 -
pipenv shelldoesn't setVIRTUAL_ENVwhen using Oh My Posh.Problem
When using
pipenv shellin zsh with Oh My Posh, theVIRTUAL_ENVenvironment variable is not being set. This only occurs with the default shell activation mode (using pexpect). Usingpipenv shell --fancyworks correctly.Root Cause
The default shell activation mode (compat mode) uses pexpect to spawn a shell and then sends the activate script as a command. Oh My Posh hooks into shell initialization and interferes with the
VIRTUAL_ENVvariable set by the activate script.In contrast,
--fancymode setsVIRTUAL_ENVdirectly in the environment before spawning the shell withos.execvp, so Oh My Posh sees it from the start.Solution
Automatically enable fancy mode when Oh My Posh is detected (via the
POSH_THEMEenvironment variable). This is similar to how Windows and pwsh already force fancy mode.Changes
pipenv/cli/command.pyto detect Oh My Posh via thePOSH_THEMEenvironment variable and automatically enable fancy mode.Testing
Users with Oh My Posh can test by running:
Pull Request opened by Augment Code with guidance from the PR author