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

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

  •  
  •   mmddisa · 2023-07-15 13:12:55 +08:00 · 3053 次点击
    这是一个创建于 479 天前的主题,其中的信息可能已经有所发展或是发生改变。

    安装 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  
       2023-07-15 13:16:36 +08:00
    排个版吧
    mmddisa
        2
    mmddisa  
    OP
       2023-07-15 13:21:28 +08:00
    @elechi 刚刚忘记添加代码块了,现在已添加
    Thymolblue
        3
    Thymolblue  
       2023-07-15 13:24:11 +08:00 via Android
    13900k 也需要 700ms ,我是直接放弃了🤔
    ncepuzs
        4
    ncepuzs  
       2023-07-15 13:28:14 +08:00   ❤️ 2
    所以早就换用 https://starship.rs/
    开箱默认配置就很好用
    ysc3839
        5
    ysc3839  
       2023-07-15 13:39:56 +08:00 via Android
    我选择 MSYS2+zsh+oh-my-zsh+powerlevel10k
    thinkershare
        6
    thinkershare  
       2023-07-15 13:43:28 +08:00
    @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  
       2023-07-15 13:44:27 +08:00
    oh-my-posh init pwsh --config $主题文件本地路径 | Invoke-Expression
    thinkershare
        8
    thinkershare  
       2023-07-15 13:45:49 +08:00
    这样延迟就不会超过 100ms 了。
    hez2010
        9
    hez2010  
       2023-07-15 14:35:34 +08:00
    PowerShell 会连接微软服务器校验加载的模块的数字签名,网络不好的话就会启动时间很长,因为一直会等到网络超时。
    有个方法是启动 pwsh 的时候带上参数 -noni ,不过这样会导致 PowerShell 不能交互式地处理命令(比如命令执行中途询问你输入什么的)。
    kid1412621
        10
    kid1412621  
       2023-07-15 14:51:35 +08:00
    @thinkershare 和 `oh-my-posh init pwsh --config $env:POSH_THEMES_PATH/xxx.omp.json | Invoke-Expression` 的区别是?
    VagrantZ
        11
    VagrantZ  
       2023-07-15 15:51:27 +08:00
    加个 -nologo ,至少不想看到提醒加载花了多少时间
    lete
        12
    lete  
       2023-07-15 16:16:51 +08:00
    可能是你使用的主题是 http 的链接,可能会有缓存,但因该会有检测主题更新的机制吧?(个人猜测)
    Jirajine
        13
    Jirajine  
       2023-07-15 16:24:46 +08:00
    @ncepuzs 其实 ohmyposh 只是继承了个名字,早就重写过变成和 starship 一样的通用 shell prompt 了。
    diagnostics
        14
    diagnostics  
       2023-07-15 17:16:02 +08:00
    用 Windows 就别用命令行了,纯给自己找罪受。Windows 编程开发效率不高
    mmddisa
        15
    mmddisa  
    OP
       2023-07-15 17:17:32 +08:00
    @diagnostics 确实,刚刚折腾了一会儿,发现就连命令补全这么基础的功能都远远不及 mac zsh 的 autocompletion
    cosette
        16
    cosette  
       2023-07-15 17:32:41 +08:00
    @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  
       2023-07-15 17:35:14 +08:00 via Android
    楼主用的什么主题
    mmddisa
        18
    mmddisa  
    OP
       2023-07-15 17:36:33 +08:00
    @cosette 我刚刚也换了 starship ,启动速度挽救回来了,不过 powershell 的自动补全还是残废,之前用 mac zsh 的时候能实现函数的 inliine 预测,powershell 必须要按一个键不说,还没几个函数能预测
    Nasei
        19
    Nasei  
       2023-07-15 17:41:36 +08:00
    如果你习惯 linux 那种 shell ,可以用 wsl1
    sayakafs
        20
    sayakafs  
       2023-07-18 13:34:45 +08:00
    我换了 starship ,没快了多少,可能是其他模块加载时间比较长,建议参考这个文章排查一下
    sayakafs
        21
    sayakafs  
       2023-07-18 13:35:31 +08:00
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1009 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 21:15 · PVG 05:15 · LAX 13:15 · JFK 16:15
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.