我只想让PowerShell成为白色背景上的黑色文字.但是,PowerShell v5突出显示了我的命令,并使它们变黄,这是不可能看到的.有没有办法在PowerShell中关闭所有语法高亮?
我已经为 PowerShell 安装了 PSReadline 模块,以便从 PowerShell 中的 Bash 获取按键绑定。我启用了 Vi-Mode,效果很好。
问题是:在 Vim 中我总是使用 j, k 退出插入模式。这意味着:我首先快速输入 j,然后输入 k。如果我真的想输入 j 和 k,那么我只需在输入 j 后等待超时即可。
如何在 PSReadline 的 Vi-Mode 中执行相同操作?我已经尝试过:Set-PSReadlineKeyHandler -Chord 'j', 'k' ViCommandMode
,但后来我无法输入j
或k
了。有任何想法吗?
我在Powershell上使用了很棒的PSReadLine模块,我真的很喜欢这是我的命令历史.但我需要重新安装我的系统.在全新安装PSReadLine之后,保存此历史记录(可能是文件)的最简单方法是什么?
我在Windows 7 SP1计算机上将PowerShell从4.0升级到5.0(2016年2月发布).
该$PSVersionTable
节目的PowerShell 5.0,但外壳没有在Windows 10中的相同的功能的PowerShell 5.0.
区别:
为什么会有区别?
如何获取/启用这些缺失的功能?
根据此博客,我已经美化了Powershell ,但是Operator
和Parameter
如下所示为灰色:
所以我通过Set-PSReadlineOption
以下方式更改它们的颜色:
Set-PSReadlineOption -TokenKind Operator -ForegroundColor Yellow
Run Code Online (Sandbox Code Playgroud)
但出现以下错误:
Set-PSReadLineOption:找不到与参数名称“ TokenKind”匹配的参数?
???? ?:1 ??:22
- Set-PSReadlineOption -TokenKind运算符-ForegroundColor黄色
- CategoryInfo:InvalidArgument:(:) [Set-PSReadLineOption]?ParameterBindingException
- FullyQualifiedErrorId:NamedParameterNotFound,Microsoft.PowerShell.SetPSReadLineOption
但是显示的帮助文件Set-PSReadlineOption
显示它具有一个TokenKind
参数,Operator
而该参数又可以作为其参数。
我很困惑为什么会发生此错误。
我的powershell版本是
感谢您的任何建议!
我正在使用 powershell VI 模式
Set-PSReadlineOption -EditMode vi
Run Code Online (Sandbox Code Playgroud)
能够使用 VI 命令编辑该行真是太棒了,但是有一件事情很烦人。使用向上和向下箭头导航历史记录时,光标始终从行的开头而不是末尾开始。即:如果我的历史中有以下命令
svn help x-shelve --list
Run Code Online (Sandbox Code Playgroud)
那么我希望光标(由管道 | 表示)像
svn help x-shelve --list|
Run Code Online (Sandbox Code Playgroud)
而不是
|svn help x-shelve --list
Run Code Online (Sandbox Code Playgroud)
有办法设置吗?
Get-PSReadLineKeyHandler : A parameter cannot be found that matches parameter name 'Key'.
At line:380 char:43
+ if ((Get-PSReadLineKeyHandler -Key Spacebar).Function -eq ...
+ ~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-PSReadLineKeyHandler], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.GetKeyHandlerCommand
Get-PSReadLineKeyHandler : A parameter cannot be found that matches parameter name 'Key'.
At line:383 char:43
+ if ((Get-PSReadLineKeyHandler -Key Enter).Function -eq 'O ...
+ ~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-PSReadLineKeyHandler], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.GetKeyHandlerCommand
Run Code Online (Sandbox Code Playgroud)
每当我打开 powershell 时都会出现此信息。我可以做什么来解决这个问题?
寻找解决方案。
我正在尝试更改 PSReadline 的 -PredictionViewStyle 选项,但收到错误“Set-PSReadLineOption:找不到与参数名称“PredictionViewStyle”匹配的参数。”
这是全新安装,Set-PSReadLineOption -PredictionSource History 有效。
请问有什么建议吗?
我最近给自己买了一台新的 Windows 11 笔记本电脑,并开始探索 powershell。以前从未在 Windows 上使用过它,但我是 Mac 的频繁用户,zsh
所以并不是全新的。
我将 Powershell 升级到7.2.1
,但注意到我习惯使用 Oh My Zsh 的自动建议类型功能丢失了。经过一番搜索后,我安装了PSReadLine
,并使用以下命令设置了我的个人资料:
Import-Module PSReadLine\n\nSet-PSReadLineOption -PredictionSource History\n\nSet-PSReadLineOption -HistorySearchCursorMovesToEnd\nSet-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward\nSet-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward\n\nSet-PSReadLineKeyHandler -Key Tab -Function Complete\n
Run Code Online (Sandbox Code Playgroud)\n这比以前好多了,但我注意到我不能部分接受自动完成。
\n例如,这是我的历史的一部分:
\nNew-item \xe2\x80\x93type file \xe2\x80\x93force $profile\n
Run Code Online (Sandbox Code Playgroud)\n如果我现在尝试创建一个文件test-file
,然后开始输入New-Item
,我确实得到了建议。我想接受直到 结束-force
,或者可能直到file
。无论我尝试什么组合键,这种情况都不会发生(徒劳地尝试了Ctrl+ \xe2\x86\x92、Shift+ \xe2\x86\x92、Alt+ \xe2\x86\x92、Fn+ )。\xe2\x86\x92
当然,我可以接受完整的建议并删除我不需要的内容。虽然对于这个例子来说,这确实无关紧要,但对于仅在初始部分出现匹配的长命令来说,这会很烦人。所以,我的问题是部分接受建议的组合是什么,或者如果需要单独启用,我该怎么做? …
在Win 10上可用,但在服务器2012 R2上不可用。
PS> Get-PSReadlineKeyHandler
Get-PSReadlineKeyHandler : The term 'Get-PSReadlineKeyHandler' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:1
+ Get-PSReadlineKeyHandler
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-PSReadlineKeyHandler:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud)
可以确认我正在运行v5
PS> $PSVersionTable
Name Value
---- -----
PSVersion 5.0.10586.117
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.10586.117 …
Run Code Online (Sandbox Code Playgroud) powershell ×11
psreadline ×11
intellisense ×1
interactive ×1
oh-my-posh ×1
powershell-7 ×1
terminal ×1
windows ×1
windows-11 ×1