V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
mmddisa
V2EX  ›  PowerShell

oh-my-posh 导致 powershell 启动缓慢

  •  
  •   mmddisa · 287 天前 · 2554 次点击
    这是一个创建于 287 天前的主题,其中的信息可能已经有所发展或是发生改变。

    安装 oh-my-posh 后,powershell 启动异常缓慢,且似乎受网络影响,网络正常时启动需 1900ms 左右: 若关闭网络,则需要 11 秒还多:

    试过将 oh-my-posh 加入 windows defender 等方法,似乎没有用

    附上网络正常/断开时的 Debug 信息:

    网络正常时:

    Cache path: C:\Users\login\AppData\Local\oh-my-posh
    
    Config path: C:\Users\login\AppData\Local\Programs\oh-my-posh\themes\cert.omp.json
    
    Logs:
    
    [DEBUG] 13:06:43.411 shell.go:Getenv:397 → NO DATA
    [TRACE] 13:06:43.411 shell.go:Getenv(TERM_PROGRAM) - 0s
    [DEBUG] 13:06:43.411 shell.go:Getenv:397 → C:\Users\login\AppData\Local
    [TRACE] 13:06:43.411 shell.go:Getenv(LOCALAPPDATA) - 0s
    [TRACE] 13:06:43.411 shell_windows.go:CachePath() - 0s
    [DEBUG] 13:06:43.412 shell.go:Getenv:397 → C:\Users\login\AppData\Local\Programs\oh-my-posh\themes\cert.omp.json
    [TRACE] 13:06:43.412 shell.go:Getenv(POSH_THEME) - 0s
    [DEBUG] 13:06:43.440 shell.go:Shell:644 → process name: pwsh.exe
    [TRACE] 13:06:43.440 shell.go:Shell() - 28.6409ms
    [TRACE] 13:06:43.440 shell.go:resolveConfigPath() - 28.6409ms
    [TRACE] 13:06:43.440 shell.go:Init() - 29.7168ms
    [TRACE] 13:06:43.440 shell.go:Flags() - 0s
    [TRACE] 13:06:43.441 config.go:loadConfig() - 523.2µs
    [TRACE] 13:06:43.441 shell.go:Flags() - 0s
    [DEBUG] 13:06:43.441 shell.go:Getenv:397 → NO DATA
    [TRACE] 13:06:43.441 shell.go:Getenv(OMP_CACHE_DISABLED) - 0s
    [TRACE] 13:06:43.441 shell_windows.go:WindowsRegistryKeyValue(HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM\ColorizationColor) - 0s
    [TRACE] 13:06:43.441 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.441 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.441 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.441 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.441 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.441 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.441 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.441 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.441 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.441 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.441 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.441 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.441 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.441 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.441 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.441 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.441 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.441 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.441 shell.go:GOOS() - 0s
    [DEBUG] 13:06:43.441 shell_windows.go:WindowsRegistryKeyValue:206 → ColorizationColor(DWORD): 0xC40078D4
    [TRACE] 13:06:43.441 shell.go:Shell() - 0s
    [DEBUG] 13:06:43.441 shell.go:Getenv:397 → 7.3.6
    [TRACE] 13:06:43.441 shell.go:Getenv(POSH_SHELL_VERSION) - 0s
    [DEBUG] 13:06:43.441 debug.go:PrintDebug:23 → Segment: Title
    [TRACE] 13:06:43.441 shell.go:Flags() - 0s
    [DEBUG] 13:06:43.441 block.go:Debug:280 → Segment: session
    [TRACE] 13:06:43.441 shell.go:GOOS() - 0s
    [DEBUG] 13:06:43.441 shell.go:Pwd:427 → C:\Users\login
    [TRACE] 13:06:43.441 shell.go:Pwd() - 0s
    [DEBUG] 13:06:43.441 shell_windows.go:56 → C:\Users\login
    [TRACE] 13:06:43.441 shell.go:GOOS() - 0s
    [DEBUG] 13:06:43.441 shell.go:Getenv:397 → NO DATA
    [TRACE] 13:06:43.441 shell.go:Getenv(SSH_CONNECTION) - 0s
    [DEBUG] 13:06:43.441 shell.go:Getenv:397 → NO DATA
    [TRACE] 13:06:43.441 shell.go:Getenv(SSH_CLIENT) - 0s
    [TRACE] 13:06:43.441 shell_windows.go:Root() - 0s
    [TRACE] 13:06:43.441 shell.go:Shell() - 0s
    [TRACE] 13:06:43.441 shell.go:ErrorCode() - 0s
    [TRACE] 13:06:43.441 shell_windows.go:IsWsl() - 0s
    [TRACE] 13:06:43.442 shell.go:Pwd() - 0s
    [DEBUG] 13:06:43.442 shell_windows.go:56 → C:\Users\login
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [DEBUG] 13:06:43.442 shell.go:User:548 → login
    [TRACE] 13:06:43.442 shell.go:User() - 0s
    [DEBUG] 13:06:43.442 shell.go:Host:560 → Avalon
    [TRACE] 13:06:43.442 shell.go:Host() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [DEBUG] 13:06:43.442 shell.go:Getenv:397 → NO DATA
    [TRACE] 13:06:43.442 shell.go:Getenv(SHLVL) - 0s
    [TRACE] 13:06:43.442 shell.go:TemplateCache() - 1.0664ms
    [TRACE] 13:06:43.442 shell.go:TemplateCache() - 0s
    [TRACE] 13:06:43.442 shell.go:Shell() - 0s
    [DEBUG] 13:06:43.442 block.go:Debug:280 → Segment: path
    [TRACE] 13:06:43.442 shell.go:Pwd() - 0s
    [DEBUG] 13:06:43.442 shell_windows.go:56 → C:\Users\login
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:Pwd() - 0s
    [TRACE] 13:06:43.442 shell.go:Shell() - 0s
    [TRACE] 13:06:43.442 shell.go:Flags() - 0s
    [DEBUG] 13:06:43.442 properties.go:GetBool:22 → mapped_locations_enabled: true
    [DEBUG] 13:06:43.442 properties.go:GetString:28 → 
    [DEBUG] 13:06:43.442 properties.go:GetString:28 → 
    [DEBUG] 13:06:43.442 shell_windows.go:56 → C:\Users\login
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [DEBUG] 13:06:43.442 properties.go:GetString:28 → ~
    [DEBUG] 13:06:43.442 properties.go:GetKeyValueMap:46 → mapped_locations: map[]
    [TRACE] 13:06:43.442 shell.go:PathSeparator() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:PathSeparator() - 0s
    [TRACE] 13:06:43.442 shell.go:PathSeparator() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:PathSeparator() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:PathSeparator() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.442 shell.go:PathSeparator() - 0s
    [TRACE] 13:06:43.442 shell.go:Pwd() - 0s
    [TRACE] 13:06:43.442 shell_windows.go:IsWsl() - 0s
    [TRACE] 13:06:43.442 shell.go:StackCount() - 0s
    [DEBUG] 13:06:43.443 win32_windows.go:isWriteable:299 → not current user or in group
    [DEBUG] 13:06:43.443 win32_windows.go:isWriteable:303 → current user is member of S-1-5-32-544
    [DEBUG] 13:06:43.443 win32_windows.go:isWriteable:311 ↓
        WRITE_DAC
        WRITE_OWNER
        SYNCHRONIZE
        DELETE
        READ_CONTROL
    [DEBUG] 13:06:43.443 win32_windows.go:isWriteable:313 → user has write access
    [TRACE] 13:06:43.443 shell_windows.go:DirIsWritable() - 524µs
    [TRACE] 13:06:43.443 shell.go:TemplateCache() - 0s
    [TRACE] 13:06:43.443 shell.go:TemplateCache() - 0s
    [TRACE] 13:06:43.443 shell.go:Shell() - 0s
    [DEBUG] 13:06:43.443 block.go:Debug:280 → Segment: git
    [TRACE] 13:06:43.443 shell.go:Pwd() - 0s
    [DEBUG] 13:06:43.443 shell_windows.go:56 → C:\Users\login
    [TRACE] 13:06:43.443 shell.go:GOOS() - 0s
    [TRACE] 13:06:43.443 shell.go:GOOS() - 0s
    [ERROR] 13:06:43.447 shell.go:CommandPath:602 → exec: "git.exe": executable file not found in %PATH%
    [TRACE] 13:06:43.447 shell.go:CommandPath(git.exe) - 4.2052ms
    [TRACE] 13:06:43.447 shell.go:HasCommand(git.exe) - 4.2052ms
    [DEBUG] 13:06:43.447 block.go:Debug:280 → Segment: time
    [TRACE] 13:06:43.447 shell.go:Pwd() - 0s
    [DEBUG] 13:06:43.447 shell_windows.go:56 → C:\Users\login
    [TRACE] 13:06:43.447 shell.go:GOOS() - 0s
    [DEBUG] 13:06:43.447 properties.go:GetString:28 → 15:04
    [TRACE] 13:06:43.447 shell.go:TemplateCache() - 0s
    [TRACE] 13:06:43.448 shell.go:TemplateCache() - 0s
    [TRACE] 13:06:43.448 shell.go:Shell() - 0s
    [DEBUG] 13:06:43.448 shell.go:Getenv:397 → C:\Users\login\AppData\Local
    [TRACE] 13:06:43.448 shell.go:Getenv(LOCALAPPDATA) - 0s
    [TRACE] 13:06:43.448 shell_windows.go:CachePath() - 0s
    [TRACE] 13:06:43.448 shell.go:Flags() - 0s
    

    网络断开时:

    Cache path: C:\Users\login\AppData\Local\oh-my-posh
    
    Config path: C:\Users\login\AppData\Local\Programs\oh-my-posh\themes\cert.omp.json
    
    Logs:
    
    [DEBUG] 13:08:36.385 shell.go:Getenv:397 → NO DATA
    [TRACE] 13:08:36.385 shell.go:Getenv(TERM_PROGRAM) - 0s
    [DEBUG] 13:08:36.385 shell.go:Getenv:397 → C:\Users\login\AppData\Local
    [TRACE] 13:08:36.385 shell.go:Getenv(LOCALAPPDATA) - 0s
    [TRACE] 13:08:36.385 shell_windows.go:CachePath() - 0s
    [DEBUG] 13:08:36.385 shell.go:Getenv:397 → C:\Users\login\AppData\Local\Programs\oh-my-posh\themes\cert.omp.json
    [TRACE] 13:08:36.385 shell.go:Getenv(POSH_THEME) - 0s
    [DEBUG] 13:08:36.412 shell.go:Shell:644 → process name: pwsh.exe
    [TRACE] 13:08:36.412 shell.go:Shell() - 26.4397ms
    [TRACE] 13:08:36.412 shell.go:resolveConfigPath() - 26.4397ms
    [TRACE] 13:08:36.412 shell.go:Init() - 26.9528ms
    [TRACE] 13:08:36.412 shell.go:Flags() - 0s
    [TRACE] 13:08:36.412 config.go:loadConfig() - 528.2µs
    [TRACE] 13:08:36.412 shell.go:Flags() - 0s
    [DEBUG] 13:08:36.412 shell.go:Getenv:397 → NO DATA
    [TRACE] 13:08:36.412 shell.go:Getenv(OMP_CACHE_DISABLED) - 0s
    [TRACE] 13:08:36.412 shell_windows.go:WindowsRegistryKeyValue(HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM\ColorizationColor) - 0s
    [TRACE] 13:08:36.412 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.412 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.412 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.412 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.412 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.412 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.412 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.412 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.412 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.412 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.412 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.412 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.412 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.412 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.412 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.412 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.412 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.412 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.412 shell.go:GOOS() - 0s
    [DEBUG] 13:08:36.412 shell_windows.go:WindowsRegistryKeyValue:206 → ColorizationColor(DWORD): 0xC40078D4
    [TRACE] 13:08:36.412 shell.go:Shell() - 0s
    [DEBUG] 13:08:36.412 shell.go:Getenv:397 → 7.3.6
    [TRACE] 13:08:36.412 shell.go:Getenv(POSH_SHELL_VERSION) - 0s
    [DEBUG] 13:08:36.412 debug.go:PrintDebug:23 → Segment: Title
    [TRACE] 13:08:36.412 shell.go:Flags() - 0s
    [DEBUG] 13:08:36.412 block.go:Debug:280 → Segment: session
    [TRACE] 13:08:36.412 shell.go:GOOS() - 0s
    [DEBUG] 13:08:36.412 shell.go:Pwd:427 → C:\Users\login
    [TRACE] 13:08:36.412 shell.go:Pwd() - 0s
    [DEBUG] 13:08:36.412 shell_windows.go:56 → C:\Users\login
    [TRACE] 13:08:36.412 shell.go:GOOS() - 0s
    [DEBUG] 13:08:36.412 shell.go:Getenv:397 → NO DATA
    [TRACE] 13:08:36.412 shell.go:Getenv(SSH_CONNECTION) - 0s
    [DEBUG] 13:08:36.412 shell.go:Getenv:397 → NO DATA
    [TRACE] 13:08:36.412 shell.go:Getenv(SSH_CLIENT) - 0s
    [TRACE] 13:08:36.413 shell_windows.go:Root() - 526.5µs
    [TRACE] 13:08:36.413 shell.go:Shell() - 0s
    [TRACE] 13:08:36.413 shell.go:ErrorCode() - 0s
    [TRACE] 13:08:36.413 shell_windows.go:IsWsl() - 0s
    [TRACE] 13:08:36.413 shell.go:Pwd() - 0s
    [DEBUG] 13:08:36.413 shell_windows.go:56 → C:\Users\login
    [TRACE] 13:08:36.413 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.413 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.413 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.413 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.413 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.413 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.413 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.413 shell.go:GOOS() - 0s
    [DEBUG] 13:08:36.413 shell.go:User:548 → login
    [TRACE] 13:08:36.413 shell.go:User() - 0s
    [DEBUG] 13:08:36.413 shell.go:Host:560 → Avalon
    [TRACE] 13:08:36.413 shell.go:Host() - 0s
    [TRACE] 13:08:36.413 shell.go:GOOS() - 0s
    [DEBUG] 13:08:36.413 shell.go:Getenv:397 → NO DATA
    [TRACE] 13:08:36.413 shell.go:Getenv(SHLVL) - 0s
    [TRACE] 13:08:36.413 shell.go:TemplateCache() - 1.1125ms
    [TRACE] 13:08:36.413 shell.go:TemplateCache() - 0s
    [TRACE] 13:08:36.413 shell.go:Shell() - 0s
    [DEBUG] 13:08:36.414 block.go:Debug:280 → Segment: path
    [TRACE] 13:08:36.414 shell.go:Pwd() - 0s
    [DEBUG] 13:08:36.414 shell_windows.go:56 → C:\Users\login
    [TRACE] 13:08:36.414 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.414 shell.go:Pwd() - 0s
    [TRACE] 13:08:36.414 shell.go:Shell() - 0s
    [TRACE] 13:08:36.414 shell.go:Flags() - 0s
    [DEBUG] 13:08:36.414 properties.go:GetBool:22 → mapped_locations_enabled: true
    [DEBUG] 13:08:36.414 properties.go:GetString:28 → 
    [DEBUG] 13:08:36.414 properties.go:GetString:28 → 
    [DEBUG] 13:08:36.414 shell_windows.go:56 → C:\Users\login
    [TRACE] 13:08:36.414 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.414 shell.go:GOOS() - 0s
    [DEBUG] 13:08:36.414 properties.go:GetString:28 → ~
    [DEBUG] 13:08:36.414 properties.go:GetKeyValueMap:46 → mapped_locations: map[]
    [TRACE] 13:08:36.414 shell.go:PathSeparator() - 0s
    [TRACE] 13:08:36.414 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.414 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.414 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.414 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.414 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.414 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.414 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.414 shell.go:PathSeparator() - 0s
    [TRACE] 13:08:36.414 shell.go:PathSeparator() - 0s
    [TRACE] 13:08:36.414 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.414 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.414 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.414 shell.go:PathSeparator() - 0s
    [TRACE] 13:08:36.414 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.414 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.414 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.414 shell.go:PathSeparator() - 0s
    [TRACE] 13:08:36.414 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.414 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.414 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.414 shell.go:PathSeparator() - 0s
    [TRACE] 13:08:36.414 shell.go:Pwd() - 0s
    [TRACE] 13:08:36.414 shell_windows.go:IsWsl() - 0s
    [TRACE] 13:08:36.414 shell.go:StackCount() - 0s
    [DEBUG] 13:08:36.415 win32_windows.go:isWriteable:299 → not current user or in group
    [DEBUG] 13:08:36.415 win32_windows.go:isWriteable:303 → current user is member of S-1-5-32-544
    [DEBUG] 13:08:36.415 win32_windows.go:isWriteable:311 ↓
        WRITE_DAC
        WRITE_OWNER
        SYNCHRONIZE
        DELETE
        READ_CONTROL
    [DEBUG] 13:08:36.415 win32_windows.go:isWriteable:313 → user has write access
    [TRACE] 13:08:36.415 shell_windows.go:DirIsWritable() - 518.6µs
    [TRACE] 13:08:36.415 shell.go:TemplateCache() - 0s
    [TRACE] 13:08:36.415 shell.go:TemplateCache() - 0s
    [TRACE] 13:08:36.415 shell.go:Shell() - 0s
    [DEBUG] 13:08:36.415 block.go:Debug:280 → Segment: git
    [TRACE] 13:08:36.415 shell.go:Pwd() - 0s
    [DEBUG] 13:08:36.415 shell_windows.go:56 → C:\Users\login
    [TRACE] 13:08:36.415 shell.go:GOOS() - 0s
    [TRACE] 13:08:36.415 shell.go:GOOS() - 0s
    [ERROR] 13:08:36.419 shell.go:CommandPath:602 → exec: "git.exe": executable file not found in %PATH%
    [TRACE] 13:08:36.419 shell.go:CommandPath(git.exe) - 4.1797ms
    [TRACE] 13:08:36.419 shell.go:HasCommand(git.exe) - 4.1797ms
    [DEBUG] 13:08:36.419 block.go:Debug:280 → Segment: time
    [TRACE] 13:08:36.419 shell.go:Pwd() - 0s
    [DEBUG] 13:08:36.419 shell_windows.go:56 → C:\Users\login
    [TRACE] 13:08:36.419 shell.go:GOOS() - 0s
    [DEBUG] 13:08:36.419 properties.go:GetString:28 → 15:04
    [TRACE] 13:08:36.419 shell.go:TemplateCache() - 0s
    [TRACE] 13:08:36.419 shell.go:TemplateCache() - 0s
    [TRACE] 13:08:36.419 shell.go:Shell() - 0s
    [DEBUG] 13:08:36.419 shell.go:Getenv:397 → C:\Users\login\AppData\Local
    [TRACE] 13:08:36.419 shell.go:Getenv(LOCALAPPDATA) - 0s
    [TRACE] 13:08:36.419 shell_windows.go:CachePath() - 0s
    [TRACE] 13:08:36.419 shell.go:Flags() - 0s
    
    21 条回复    2023-07-18 13:35:31 +08:00
    elechi
        1
    elechi  
       287 天前
    排个版吧
    mmddisa
        2
    mmddisa  
    OP
       287 天前
    @elechi 刚刚忘记添加代码块了,现在已添加
    Thymolblue
        3
    Thymolblue  
       287 天前 via Android
    13900k 也需要 700ms ,我是直接放弃了🤔
    ncepuzs
        4
    ncepuzs  
       287 天前   ❤️ 2
    所以早就换用 https://starship.rs/
    开箱默认配置就很好用
    ysc3839
        5
    ysc3839  
       287 天前 via Android
    我选择 MSYS2+zsh+oh-my-zsh+powerlevel10k
    thinkershare
        6
    thinkershare  
       287 天前
    @mmddisa 使用本地的配置主题: C:\Users\$User\Documents\PowerShell\Microsoft.PowerShell_profile.ps1 配置

    #------------------------------- Import Modules BEGIN -------------------------------
    # Import-Module posh-git
    Import-Module PSReadLine
    #------------------------------- Import Modules END -------------------------------

    oh-my-posh init pwsh --config "C:\Users\think\Documents\PowerShell\.posh.json" | Invoke-Expression

    #------------------------------- Set Hot-keys BEGIN -------------------------------
    # 设置预测文本来源为历史记录
    Set-PSReadLineOption -PredictionSource History

    # 每次回溯输入历史,光标定位于输入内容末尾
    Set-PSReadLineOption -HistorySearchCursorMovesToEnd

    # 设置 Tab 为菜单补全和 Intellisense
    Set-PSReadLineKeyHandler -Key "Tab" -Function MenuComplete

    # 设置 Ctrl+d 为退出 PowerShell
    Set-PSReadlineKeyHandler -Key "Ctrl+d" -Function ViExit

    # 设置 Ctrl+z 为撤销
    Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo

    # 设置向上键为后向搜索历史记录
    Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward

    # 设置向下键为前向搜索历史纪录
    Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
    #------------------------------- Set Hot-keys END -------------------------------

    让后将 主题文件放置到 ps1 文件夹 重命名一下: .posh.json 就好了,主要问题还是国内的网络有问题。
    thinkershare
        7
    thinkershare  
       287 天前
    oh-my-posh init pwsh --config $主题文件本地路径 | Invoke-Expression
    thinkershare
        8
    thinkershare  
       287 天前
    这样延迟就不会超过 100ms 了。
    hez2010
        9
    hez2010  
       287 天前
    PowerShell 会连接微软服务器校验加载的模块的数字签名,网络不好的话就会启动时间很长,因为一直会等到网络超时。
    有个方法是启动 pwsh 的时候带上参数 -noni ,不过这样会导致 PowerShell 不能交互式地处理命令(比如命令执行中途询问你输入什么的)。
    kid1412621
        10
    kid1412621  
       287 天前
    @thinkershare 和 `oh-my-posh init pwsh --config $env:POSH_THEMES_PATH/xxx.omp.json | Invoke-Expression` 的区别是?
    VagrantZ
        11
    VagrantZ  
       287 天前
    加个 -nologo ,至少不想看到提醒加载花了多少时间
    lete
        12
    lete  
       287 天前
    可能是你使用的主题是 http 的链接,可能会有缓存,但因该会有检测主题更新的机制吧?(个人猜测)
    Jirajine
        13
    Jirajine  
       287 天前
    @ncepuzs 其实 ohmyposh 只是继承了个名字,早就重写过变成和 starship 一样的通用 shell prompt 了。
    diagnostics
        14
    diagnostics  
       287 天前
    用 Windows 就别用命令行了,纯给自己找罪受。Windows 编程开发效率不高
    mmddisa
        15
    mmddisa  
    OP
       287 天前
    @diagnostics 确实,刚刚折腾了一会儿,发现就连命令补全这么基础的功能都远远不及 mac zsh 的 autocompletion
    cosette
        16
    cosette  
       287 天前
    @mmddisa 稍微挽救一下,zsh 的补全也还是不如 fishshell 好用
    ```
    # Auto-Completion
    Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
    Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
    Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
    ```
    ohmyposh 启动确实慢,已经换 starship
    lee88688
        17
    lee88688  
       287 天前 via Android
    楼主用的什么主题
    mmddisa
        18
    mmddisa  
    OP
       287 天前
    @cosette 我刚刚也换了 starship ,启动速度挽救回来了,不过 powershell 的自动补全还是残废,之前用 mac zsh 的时候能实现函数的 inliine 预测,powershell 必须要按一个键不说,还没几个函数能预测
    Nasei
        19
    Nasei  
       287 天前
    如果你习惯 linux 那种 shell ,可以用 wsl1
    sayakafs
        20
    sayakafs  
       284 天前
    我换了 starship ,没快了多少,可能是其他模块加载时间比较长,建议参考这个文章排查一下
    sayakafs
        21
    sayakafs  
       284 天前
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1117 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 18:07 · PVG 02:07 · LAX 11:07 · JFK 14:07
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.