Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
666 views
in Technique[技术] by (71.8m points)

visual studio code - Hiding the full file path in a PowerShell command prompt in VSCode

So I've just downloaded Visual Studio Code to use as my default IDE for learning Python. I'm running on a 64-bit machine so I made the default terminal windows powershell.

The place where I'll be saving most of my files is about 8 folders deep which all show up in the terminal before any commands can be written. Is there any way to hide or shorten the file path in the terminal?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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!

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...