标签: psreadline

如何在控制台中关闭语法高亮?

我只想让PowerShell成为白色背景上的黑色文字.但是,PowerShell v5突出显示了我的命令,并使它们变黄,这是不可能看到的.有没有办法在PowerShell中关闭所有语法高亮?

powershell syntax-highlighting powershell-5.0 psreadline

10
推荐指数
4
解决办法
4640
查看次数

在 Vi-Mode 的 PSReadline 中重新绑定转义符

我已经为 PowerShell 安装了 PSReadline 模块,以便从 PowerShell 中的 Bash 获取按键绑定。我启用了 Vi-Mode,效果很好。

问题是:在 Vim 中我总是使用 j, k 退出插入模式。这意味着:我首先快速输入 j,然后输入 k。如果我真的想输入 j 和 k,那么我只需在输入 j 后等待超时即可。

如何在 PSReadline 的 Vi-Mode 中执行相同操作?我已经尝试过:Set-PSReadlineKeyHandler -Chord 'j', 'k' ViCommandMode,但后来我无法输入jk了。有任何想法吗?

powershell psreadline

7
推荐指数
1
解决办法
977
查看次数

如何在powershell PSReadLine模块中保存和加载历史记录?

我在Powershell上使用了很棒的PSReadLine模块,我真的很喜欢这是我的命令历史.但我需要重新安装我的系统.在全新安装PSReadLine之后,保存此历史记录(可能是文件)的最简单方法是什么?

powershell psreadline

6
推荐指数
1
解决办法
1583
查看次数

为什么Windows 7的PowerShell 5不具备与Windows 10相同的功能?

我在Windows 7 SP1计算机上将PowerShell从4.0升级到5.0(2016年2月发布).

$PSVersionTable节目的PowerShell 5.0,但外壳没有在Windows 10中的相同的功能的PowerShell 5.0.

区别:

  • 关键字突出显示
  • 使用Shift +箭头键选择文本
  • 使用Ctrl + C/V复制/粘贴

为什么会有区别?

如何获取/启用这些缺失的功能?

powershell windows-console powershell-5.0 psreadline

6
推荐指数
1
解决办法
964
查看次数

找不到与参数名称“ TokenKind”匹配的参数

根据此博客,我已经美化了Powershell ,但是OperatorParameter如下所示为灰色:

在此处输入图片说明 在此处输入图片说明

所以我通过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 psreadline

4
推荐指数
1
解决办法
2692
查看次数

在powershell中使用psreadline -EditMode VI如何确保光标在浏览历史记录时从行尾开始

我正在使用 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)

有办法设置吗?

powershell psreadline

4
推荐指数
1
解决办法
2291
查看次数

如何在 powershell 中输入时禁用建议

执行命令时PowerShell它会自动建议文本

在此输入图像描述

我如何禁用这些建议,如果将来我想启用这些建议,我该怎么做?

powershell intellisense interactive psreadline powershell-7

4
推荐指数
1
解决办法
1147
查看次数

Get-PSReadLineKeyHandler:找不到与参数名称“Key”匹配的参数。《Oh My Posh》中的这个是什么?

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 时都会出现此信息。我可以做什么来解决这个问题?

寻找解决方案。

powershell psreadline oh-my-posh

4
推荐指数
2
解决办法
7586
查看次数

Set-PSReadLineOption:找不到与参数名称“PredictionViewStyle”匹配的参数

我正在尝试更改 PSReadline 的 -PredictionViewStyle 选项,但收到错误“Set-PSReadLineOption:找不到与参数名称“PredictionViewStyle”匹配的参数。”

这是全新安装,Set-PSReadLineOption -PredictionSource History 有效。

请问有什么建议吗?

terminal powershell psreadline

3
推荐指数
2
解决办法
8333
查看次数

接受部分自动完成

我最近给自己买了一台新的 Windows 11 笔记本电脑,并开始探索 powershell。以前从未在 Windows 上使用过它,但我是 Mac 的频繁用户,zsh所以并不是全新的。

\n

我将 Powershell 升级到7.2.1,但注意到我习惯使用 Oh My Zsh 的自动建议类型功能丢失了。经过一番搜索后,我安装了PSReadLine,并使用以下命令设置了我的个人资料:

\n
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

例如,这是我的历史的一部分:

\n
New-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\x92Shift+ \xe2\x86\x92Alt+ \xe2\x86\x92Fn+ )。\xe2\x86\x92

\n

当然,我可以接受完整的建议并删除我不需要的内容。虽然对于这个例子来说,这确实无关紧要,但对于仅在初始部分出现匹配的长命令来说,这会很烦人。所以,我的问题是部分接受建议的组合是什么,或者如果需要单独启用,我该怎么做? …

windows powershell psreadline windows-11 powershell-7.2

3
推荐指数
1
解决办法
1043
查看次数

Server 2012 R2缺少PSReadline cmdlet?

在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 windows-server-2012-r2 psreadline

2
推荐指数
1
解决办法
900
查看次数