Ensure that the profile is empty. If you just created the profile, you can simply proceed further. If not, clear all contents in the profile. If the error action preference is set in the profile, it would become hard to troubleshoot scripts that you create in the future.
- Enter the following in the main window.
function prompt {
$Location = (Get-Location).Path.ToString()
switch -Wildcard ($Location) {
"/home/$env:USERNAME" { $Location = '~'; break }
"/home/$env:USERNAME/Documents" { $Location = 'Documents'; break }
"/home/$env:USERNAME/Downloads" { $Location = 'Downloads'; break }
"/home/$env:USERNAME/Pictures" { $Location = 'Pictures'; break }
"/home/$env:USERNAME/Videos" { $Location = 'Videos'; break }
"/home/$env:USERNAME/Music" { $Location = 'Music'; break }
"/home/$env:USERNAME/Documents/code" { $Location = 'Code'; break }
"/home/$env:USERNAME/*" { $Location = $Location.Replace("/home/$env:USERNAME/", '~/'); break }
Default { }
}
Write-Host "PS " -NoNewline
Write-Host `
($($env:USERNAME) + "@" + "$([System.Net.Dns]::GetHostByName((hostname)).HostName) ") `
-NoNewLine -ForegroundColor Cyan
Write-Host "$Location" -NoNewline -ForegroundColor Green
Write-Host ("`n> ") -NoNewline
return " "
}
- Save the profile script file.
- Click on the little bin icon at the top of the Integrated Console to kill the current PowerShell session.
- When VS Code prompts you whether you would like to restart the session, click Yes.
Your prompt should look as shown in the image below.