-
-
Notifications
You must be signed in to change notification settings - Fork 110
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
Conversation
internal/shell/powershell.go
Outdated
@@ -33,16 +33,22 @@ const hook = ` | |||
{{.EnvContent}} | |||
|
|||
$__VFOX_PID=$pid; | |||
$originalPrompt = & $function:prompt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这一步为什么要执行呢, 我们可以不执行啊, 对不对? 直接放到我们自己的prompt最后 去执行不就行啦?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
报错是因为你没有加;
吧, 我本地试了一下没问题.
思路是对的, 就是写的有些复杂了. $originalPrompt = $function:prompt;
function prompt {
$export = &'{{.SelfPath}}' env -s pwsh;
if ($export) {
Invoke-Expression -Command $export;
}
&$originalPrompt;
} |
好的,感谢您的指导,请问我接下来是再发起一个pr吗 |
在这个上面修改就行,把代码回退,重新修改就可以 |
c60c01d
to
3f67daf
Compare
1. Fix powershell prompt has been replaced, just using the original prompt.
3f67daf
to
ba12a88
Compare
@LordHumphrey 感谢贡献 👍 |
您太客气了,是我谢谢您,第一次给开源项目提PR,您给的帮助很大~ |
…function (version-fox#101) fix powershell hook script override original prompt function. --------- Co-authored-by: taowong <[email protected]> Co-authored-by: Han Li <[email protected]>
"PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) ";
这里的>
似乎会变化,如果直接返回原始prompt就出现不一致。