Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(powershell): fix powershell prompt #101

Merged
merged 3 commits into from
Mar 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions internal/shell/powershell.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ const hook = `
{{.EnvContent}}

$__VFOX_PID=$pid;
$originalPrompt = & $function:prompt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这一步为什么要执行呢, 我们可以不执行啊, 对不对? 直接放到我们自己的prompt最后 去执行不就行啦?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我试了,必须在进入prompt函数之前执行& $function:prompt,如果按照您的写法,会出现一下错误

Line |
 334 |   Invoke-Expression "$(vfox activate pwsh)"
     |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Unexpected token 'function' in expression or statement.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

报错是因为你没有加;吧, 我本地试了一下没问题.

aooohan marked this conversation as resolved.
Show resolved Hide resolved
function prompt {
$export = &"{{.SelfPath}}" env -s pwsh;
if ($export) {
Invoke-Expression -Command $export;
Invoke-Expression -Command $export;
}
return "PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) ";
return $originalPrompt;
aooohan marked this conversation as resolved.
Show resolved Hide resolved
}

Register-EngineEvent -SourceIdentifier PowerShell.Exiting -SupportEvent -Action {
Expand Down