Hiding the full file path in a PowerShell command prompt in VSCode

As @Biclops suggested, there is good info here: configure PowerShell to only show the current folder in the prompt

However, I needed more basic info to get this to work. This is a very good resource to get started: Windows PowerShell Profiles. So I first followed the steps suggested there:

[always using vscode’s integrated terminal using PowerShell]

  1. test-path $profile (is there a profile set up?)
  2. new-item -path $profile -itemtype file -force (assuming the answer to the above is false)
  3. notepad $profile (opens notepad)
  4. paste in (from the SuperUser answer above)

    function prompt {
      $p = Split-Path -leaf -path (Get-Location)
      "$p> "
    }
    
  5. save (you shouldn’t have to chose a location, it is already done for you)
  6. reload vscode – you will probably get an error message about running scripts (or just do next step before reload)
  7. Set-ExecutionPolicy RemoteSigned -Scope CurrentUser (at your integrated terminal PS prompt, also from the SuperUser answer)
  8. reload vscode
  9. You should be good to go!

Leave a Comment