Skip to content

Fix: Auto-enable fancy shell mode when Oh My Posh is detected#6488

Merged
matteius merged 1 commit intomainfrom
fix/oh-my-posh-virtual-env-6226
Dec 10, 2025
Merged

Fix: Auto-enable fancy shell mode when Oh My Posh is detected#6488
matteius merged 1 commit intomainfrom
fix/oh-my-posh-virtual-env-6226

Conversation

@matteius
Copy link
Copy Markdown
Member

Summary

Fixes #6226 - pipenv shell doesn't set VIRTUAL_ENV when using Oh My Posh.

Problem

When using pipenv shell in zsh with Oh My Posh, the VIRTUAL_ENV environment variable is not being set. This only occurs with the default shell activation mode (using pexpect). Using pipenv shell --fancy works 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_ENV variable set by the activate script.

In contrast, --fancy mode sets VIRTUAL_ENV directly in the environment before spawning the shell with os.execvp, so Oh My Posh sees it from the start.

Solution

Automatically enable fancy mode when Oh My Posh is detected (via the POSH_THEME environment variable). This is similar to how Windows and pwsh already force fancy mode.

Changes

  • Modified pipenv/cli/command.py to detect Oh My Posh via the POSH_THEME environment variable and automatically enable fancy mode.

Testing

Users with Oh My Posh can test by running:

pipenv shell
echo $VIRTUAL_ENV  # Should now show the virtualenv path

Pull Request opened by Augment Code with guidance from the PR author

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
@matteius matteius force-pushed the fix/oh-my-posh-virtual-env-6226 branch from 007adc4 to 4c027af Compare December 10, 2025 22:06
@matteius matteius merged commit cc01955 into main Dec 10, 2025
19 of 20 checks passed
@matteius matteius deleted the fix/oh-my-posh-virtual-env-6226 branch December 10, 2025 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Running pipenv shell in oh-my-posh doesn't set VIRTUAL_ENV

1 participant