powershell7, 执行速度和自动补全速度都慢的令我抓狂 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
chackchackGO
V2EX    PowerShell

powershell7, 执行速度和自动补全速度都慢的令我抓狂

  •  
  •   chackchackGO 2022 年 9 月 13 日 5907 次点击
    这是一个创建于 1261 天前的主题,其中的信息可能已经有所发展或是发生改变。

    powershell7 第一条指令的延迟大概 3s+, 后续使用 ls 指令也有 s 左右延迟, 自动补全速度也很慢.

    我没有 google 到类似的问题, 请问有类似情况的朋友吗?
    我的环境是原版 windows10, 保持着更新. version 21h2(build 19044.1889)

    29 条回复    2022-09-15 22:00:30 +08:00
    thinkershare
        1
    thinkershare  
       2022 年 9 月 13 日
    你的 powershell 7 的版本是多少?
    thinkershare
        2
    thinkershare  
       2022 年 9 月 13 日
    我的 powershell 7.2.6 在 Windows 10 / Windows 11 上很快. 感觉和 Linux bash shell 差不多, 看下 CPU 占用?
    lneoi
        3
    lneoi  
       2022 年 9 月 13 日
    我感觉每次启动特别慢,人要等傻了
    thinkershare
        4
    thinkershare  
       2022 年 9 月 13 日
    你的 Terminal 用的是什么?
    thinkershare
        5
    thinkershare  
       2022 年 9 月 13 日
    奇怪了, 我的都是秒开, 你们的为什么会慢呢? 我用的是 Windows Terminal, Terminal 常驻后台. 从来没感觉到卡过. 旧的 Powershell 的确卡的一比, 然后我就删除掉了旧的 powershell.
    lneoi
        6
    lneoi  
       2022 年 9 月 13 日
    @thinkershare 不知道是不是安装 miniconda 影响,总体在 vscode 里和微软的 terminal 会相对更慢,直接打开会快一些些
    SJ2050cn
        7
    SJ2050cn  
       2022 年 9 月 13 日
    有吗,我启动差不多 700 多 ms ,执行 ls 这种语句没延迟啊,你是不是插件装多了。
    Mithril
        8
    Mithril  
       2022 年 9 月 13 日
    我用 ZSH 进一些大点的 Git 库的文件夹就会非常卡,它总要刷 status 。
    不知道你是不是用了类似的插件。
    Huelse
        9
    Huelse  
       2022 年 9 月 13 日
    要么你插件太多,要么你用了在线配置
    kokutou
        10
    kokutou  
       2022 年 9 月 13 日 via Android
    杀毒问题吧,
    CharlieJiang
        12
    CharlieJiang  
       2022 年 9 月 13 日
    我怀疑是 Git 的问题,是不是在很大的 Git 库下
    然后以前加载 Profile 要花很多时间,不知道哪个版本之后突然就很快了
    keepeye
        13
    keepeye  
       2022 年 9 月 13 日
    我一直想问一下 powershell 有没有历史命令自动补全功能的插件?就像 ohmyzsh 或 fish 一样
    402124773
        14
    402124773  
       2022 年 9 月 13 日
    @keepeye 有的
    &t=1886s
    看看这个视频
    keepeye
        15
    keepeye  
       2022 年 9 月 13 日
    @402124773 谢谢 装了个 PSReadLine 有效果了
    rpish
        16
    rpish  
       2022 年 9 月 13 日
    @SJ2050cn 可以把 prompt 从 oh-my-posh 换到 starship 提升启动速度。
    然后在 terminal 配置里加上-NoLogo 启动参数,关闭启动提示。
    chackchackGO
        17
    chackchackGO  
    OP
       2022 年 9 月 13 日
    @thinkershare
    @SJ2050cn
    @Huelse
    用的 powershell 7.2.6
    terminal 用的 windows terminal

    没有 cpu 问题,没有安装杀毒软件(且禁用了 windows defender), 没有安装过插件和搞过在线配置. 刚刚从 microsoft 官网里下载的安装程序安装的

    我刚刚仔细手工测试发现:
    windows terminal 和在 jetbrains 系列的 terminal(指定了 powershell7 的 pwsh.exe) 第一条命令都有 0.5s~2s+较高的延迟
    (不过好像多重新开几次 shell 之后就基本只有 0.5s 了)

    直接运行 powershell7 就没有体感延迟.

    很奇怪
    不要觉得我有点钻这个细枝末节... 只是真的有时候忽然要切到 shell 看信息 第一条命令延迟 3s 和 powershell 1.0 cmd 之类的阻塞感相比 太难受了
    chackchackGO
        18
    chackchackGO  
    OP
       2022 年 9 月 13 日
    @chackchackGO 所有输错的命令 都有 0.2s+的延迟来报错. 明明 win10 自带的 powershell 1 和 cmd 都是瞬间回显的.
    真的愁人
    chackchackGO
        19
    chackchackGO  
    OP
       2022 年 9 月 13 日
    @chackchackGO 输错命令会延迟 3s+. 很劝退
    chackchackGO
        20
    chackchackGO  
    OP
       2022 年 9 月 13 日
    @thinkershare 故意多次输入错误命令(就单独输入个 's') cpu 能占用到 15%.
    就是 3.8Ghz 的 i7 9750h 的 15%..
    Huelse
        21
    Huelse  
       2022 年 9 月 13 日
    @keepeye #13 有,搜 oh-my-posh 自动补全相关的
    codingBug
        22
    codingBug  
       2022 年 9 月 13 日
    和电脑配置有关
    zhuangzhuang1988
        23
    zhuangzhuang1988  
       2022 年 9 月 13 日
    去掉插件
    我都去掉了
    软件折腾尽头 是 默认配置.
    chackchackGO
        24
    chackchackGO  
    OP
       2022 年 9 月 13 日
    @zhuangzhuang1988 我在 17 楼说过了我是刚刚安装的那种.
    我甚至主动去 powershell 文件夹里删掉了所有 module 以及从 github microsoft store 等地方重装过.
    .net 也检查过
    累了 已经去 github 提 issue 了
    thinkershare
        25
    thinkershare  
       2022 年 9 月 13 日
    @chackchackGO 这种错误, 不知道官方能否复现, 如果无法复现, 我估计官方也很难修正. 看下 powershell 有没有详细的日志, 看查查日志到底是哪里慢在哪里了.
    SpecterShell
        26
    SpecterShell  
       2022 年 9 月 14 日   1
    @keepeye #13
    安装新版 PSReadline ,然后在 profile 里添加:
    Set-PSReadLineOption -PredictionSource History
    Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete
    Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
    Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
    可以大幅度提升使用体验。其它命令详见: https://docs.microsoft.com/zh-cn/powershell/module/psreadline/about/about_psreadline_functions?view=powershell-7.2

    现在还可以用 IntelliSense 来进行命令预测: https://docs.microsoft.com/zh-cn/powershell/scripting/learn/shell/using-predictors?view=powershell-7.2
    ByteCat
        27
    ByteCat  
       2022 年 9 月 14 日
    pwsh 就是垃圾,有时候开的时候会卡住 30s 左右,然后配置文件加载失败,难用死了,是商店里下载的,装了 oh-my-pwsh ,现在换 Mac 了,真爽
    sw926
        28
    sw926  
       2022 年 9 月 15 日
    git 要装 64 位的,32 位会卡,如果用了 oh-my-posh ,换一个干净的主题
    chackchackGO
        29
    chackchackGO  
    OP
       2022 年 9 月 15 日
    @sw926 我的 git 目录在 `program files `下 非 `program files(x86)`
    是 64 位
    纯净安装的 pwsh
    我甚至尝试卸载了 git
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     3161 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 33ms UTC 10:56 PVG 18:56 LAX 02:56 JFK 05:56
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86