是否可以在已运行的完成脚本和VSCode中的下一个命令行提示符之间添加换行符。在用于powershell的ISE控制台中,它跳过几行以使其更易于阅读。我浏览了网络以寻找答案,但是我认为自己的搜索措词不正确。任何想法都会有所帮助。
答案 0 :(得分:0)
If you read the about_prompts
help file noted by Kory Gill (by running get-help about_prompts -Full
) then there are lots of examples on changing the default prompt behavior.
Run (Get-Command Prompt).ScriptBlock
to get the default layout. My default Prompt
function:
"PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) ";
# .Link
# https://go.microsoft.com/fwlink/?LinkID=225750
# .ExternalHelp System.Management.Automation.dll-help.xml
To add two line breaks after previous code output, run this:
Function Prompt {
"
PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) ";
# .Link
# https://go.microsoft.com/fwlink/?LinkID=225750
# .ExternalHelp System.Management.Automation.dll-help.xml
}
To have these settings persist, you need to add the modified function to your PowerShell profile.
Copy the above code (or what you come up with to your liking) and add that to your profile script in C:\Users\User\Documents\WindowsPowershell\Profile.ps1 as documented in about_Profiles
. This will make the desired prompt behavior persist, and will also apply in the embedded PowerShell terminal in vscode. These are the documented profile script locations in about_Profiles
:
Description Path
----------- ----
Current User, Current Host $Home\[My ]Documents\WindowsPowerShell\Profile.ps1
Current User, All Hosts $Home\[My ]Documents\Profile.ps1
All Users, Current Host $PsHome\Microsoft.PowerShell_profile.ps1
All Users, All Hosts $PsHome\Profile.ps1
Run help about_Profiles -Full
to learn more about profiles.