DEV Community

Michael Saparov
Michael Saparov

Posted on

Settings for PowerShell to show the name of virtual environment (pipenv)

  • Open PowerShell.

Open PowerShell with administrator permission.

  • Check PowerShell profile availability:

Check that you have PowerShell profile, run the command:

Test-Path $profile
Enter fullscreen mode Exit fullscreen mode

If you get False, than create profile by running the command:

New-Item -Type File -Force $profile
Enter fullscreen mode Exit fullscreen mode
  • Open the profile in editor:
notepad $profile
Enter fullscreen mode Exit fullscreen mode
  • Add the code to the profile file:
function prompt {
        # Check,  if virtual environment is activated by using  pipenv shell
        if ($env:PIPENV_ACTIVE) {
            Write-Host "(pipenv) " -NoNewline -ForegroundColor Cyan
        }
        # Check,  if virtual environment is activated by using  venv
        elseif ($env:VENV_PROMPT -eq "activated") {
            Write-Host "(venv) " -NoNewline -ForegroundColor Cyan
        }

        "PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) "
    }
Enter fullscreen mode Exit fullscreen mode
  • To change the current value of the PowerShell script launch policy, the Set-ExecutionPolicy cmdlet is used. For example, let's allow local scripts to run:
Set-ExecutionPolicy RemoteSigned
Enter fullscreen mode Exit fullscreen mode
  • For further use, restart the terminal
  • Result: Image description

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

πŸ‘‹ Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay