Hiding the full file path in a PowerShell command prompt in VSCode
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?
1 Answer
1
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]
test-path $profile
new-item -path $profile -itemtype file -force
notepad $profile
paste in (from the SuperUser answer above)
function prompt
$p = Split-Path -leaf -path (Get-Location)
"$p> "
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
You could also do
"$pwd".Split('')[-1] + '> '
to be shorter– TheIncorrigible1
Aug 31 at 2:37
"$pwd".Split('')[-1] + '> '
I wish javascript had negative indexes to arrays.... that would be so useful.
– Mark
Aug 31 at 2:55
Join the .NET darkside (actually, I don't think C# has neg indeces either)
– TheIncorrigible1
Aug 31 at 2:56
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Have you tried asking this question at superuser.com This is a stack exchange where power users answer questions like this.
– Biclops
Aug 31 at 1:04