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

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

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