gpt4 book ai didi

powershell - 如何让 powershell 在按下 Tab 键后显示建议列表?

转载 作者:行者123 更新时间:2023-12-02 23:20:29 25 4
gpt4 key购买 nike

在我公司的电脑上,当我在 powershell 中输入内容后按 Tab 键时,它会显示一个建议列表,我可以使用箭头键选择列表中的项目。例如,这是我键入“fin”然后按 tab 键时的结果:

enter image description here

如何配置 powershell 以显示该列表?我尝试将 powershell 配置文件复制到我的笔记本电脑并导入必要的模块,但它不像图片那样工作(shell 只显示第一个匹配我键入的内容,对于上面的示例,它显示 Find-Command 当我输入 fin 并按下 tab,但不是列表时)

这是个人资料:

function Test-Administrator {
$user = [Security.Principal.WindowsIdentity]::GetCurrent();
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}

Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Sorin

Import-Module Get-ChildItemColor

Set-Alias l Get-ChildItemColor -option AllScope
Set-Alias ls Get-ChildItemColorFormatWide -option AllScope

function cddash {
if ($args[0] -eq '-') {
$pwd = $OLDPWD;
} else {
$pwd = $args[0];
}
$tmp = pwd;

if ($pwd) {
Set-Location $pwd;
}
Set-Variable -Name OLDPWD -Value $tmp -Scope global;
}

Set-Alias -Name cd -value cddash -Option AllScope


# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}

最佳答案

您在该屏幕截图中运行的不仅仅是 PowerShell。是 ConEmu。因此,您可能正在使用 Posh-Git、oh-my-posh 和 PsReadline 模块运行 ConEmu。

Psreadline 提供您正在谈论的菜单功能。

满足所有先决条件并安装 PsReadLine 后,您可以根据需要修改键处理程序,以便将菜单选项分配给选项卡。默认情况下,它分配给 Ctrl + Space。

将其绑定(bind)到标签:

import-module PsReadLine
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete

关于powershell - 如何让 powershell 在按下 Tab 键后显示建议列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51959477/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com