装了 oh-my-posh 后,启动 powershell 变得非常慢

2023-03-14 20:04:13 +08:00
 systemcall
PowerShell 7.2.5
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

   A new PowerShell stable release is available: v7.3.3
   Upgrade now, or check out the release page at:
     https://aka.ms/PowerShell-Release?tag=v7.3.3

Loading personal and system profiles took 20752ms.

差不多这个水平,不知道为什么

4372 次点击
所在节点    Windows
18 条回复
statumer
2023-03-14 20:08:17 +08:00
holy shit, 20s? 别用 pwsh 了。
Gavrain
2023-03-14 20:16:35 +08:00
Windows PowerShell
版权所有( C ) Microsoft Corporation 。保留所有权利。

安装最新的 PowerShell ,了解新功能和改进! https://aka.ms/PSWindows

加载个人及系统配置文件用了 872 毫秒。

不知道题主用的什么环境啥主题,win11 才装的问题不大。
richardzhao12138
2023-03-14 20:21:28 +08:00
PowerShell 7.4.0-preview.1
Loading personal and system profiles took 10596ms.
我的也慢
gloye
2023-03-14 20:29:06 +08:00
应该是网络的原因,看看是否能够正常读取
https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json
yaoyao1128
2023-03-14 20:30:28 +08:00
github 没正常连接到吧……
systemcall
2023-03-14 20:48:11 +08:00
@gloye #4
考虑了网络原因,问了一下 new bing ,让它写了个网络判断的脚本,现在一般情况下是 2000 多 ms 可以启动,第二次会快不少,不知道是 new bing 写的代码的问题,还是别的什么问题,还是 pwsh 本来就这么慢,反正是微软那边的问题
systemcall
2023-03-14 20:57:25 +08:00
附言写不下了,补充一下我现在的真正的初始化代码:
Import-Module PSReadLine
Import-Module posh-git
oh-my-posh init pwsh --config 'C:\Users\admin\AppData\Local\Programs\oh-my-posh\themes\catppuccin_mocha.omp.json' | Invoke-Expression
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineKeyHandler -Key "Ctrl+d" -Function MenuComplete
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
Import-Module DirColors
不知道哪里有问题
rpish
2023-03-14 21:22:12 +08:00
已经转到 starship ,这个模块加载就是那么耗时,没办法。
Tumblr
2023-03-14 22:12:17 +08:00
这个模块不至于这么慢啊,我也有在用这个模块,冷启动大概 2 3 秒,热启动 1 秒左右(使用中偶尔会卡一下,1 秒内)。
我是这样调用的:oh-my-posh init pwsh -c 'D:\Program Files\oh-my-posh\themes\agnosterplus.omp.json' | Invoke-Expression
anguliuyun
2023-03-14 22:17:53 +08:00
推荐一个 rust 写的跨平台 shell - [nushell]( https://github.com/nushell/nushell)
FanyFull
2023-03-14 22:48:11 +08:00
我也感觉很慢,而且,同样很慢的,还有 windows 上的 neovim.
LokiSharp
2023-03-14 23:47:56 +08:00
pwsh 本来启动就慢 Emmmmm
billly
2023-03-15 00:25:15 +08:00
我之前试过,也是很慢,就不用了
Moha
2023-03-15 09:55:31 +08:00
我一直都这么慢,真是醉了...........
systemcall
2023-03-15 10:04:22 +08:00
@Tumblr #9
我也觉得奇怪。我是 12 代 i7 的电脑,不应该这么慢
hhjj3388
2023-03-15 11:12:57 +08:00
我的 i5 9400 的

PowerShell 7.3.0-preview.8

A new PowerShell preview release is available: v7.4.0-preview.2
Upgrade now, or check out the release page at:
https://aka.ms/PowerShell-Release?tag=v7.4.0-preview.2

Loading personal and system profiles took 515ms.
      ﮫ 0ms   11:12 AM  
hez2010
2023-03-16 08:51:43 +08:00
用旧版的 oh-my-posh 2.x ,旧版的 oh-my-posh 是 powershell 写的,加载速度很快,而新版本的 oh-my-posh 是用 go 写的,初始化巨慢无比。
isajdhs
300 天前
在项目 issue 见过这个问题,好像是因为启动时 Windows defender 会扫描 oh-my-posh ,加入白名单就行了,不过我现在用的 rust 写的 satrship ,主题较少

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/923997

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX