
Set-PSReadLineKeyHandler -Chord Tab -ViMode Command -ScriptBlock { $cOntent= "" $index = 0 [Microsoft.PowerShell.PSConsoleReadLine]::ViTabCompleteNext() [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref] $content, [ref] $index) [Microsoft.PowerShell.PSConsoleReadLine]::RevertLine() [Microsoft.PowerShell.PSConsoleReadLine]::Insert($content.Replace('\','/')) [Microsoft.PowerShell.PSConsoleReadLine]::SetCursorPosition($index) } 链接是这个: https://github.com/PowerShell/PSReadLine/issues/3205
cd 还有执行程序和.ps1 脚本都没啥问题,不过我也才用,可能会影响一些用到 cmd 工具的命令?
]]>想在 powershell 开始前使用命令删除这些 tmp 文件,结果执行命令时一边删除一边又生成了同样多的 tmp 文件
gci $env:TEMP\PS*.tmp -File | % { ri $_.FullName -Force } 那么现在问题来了,如何阻止 powershell 生成这些文件呢
]]>我有个长命令 pnpm store prune, 我希望能用pmsp 来替代这个命令 我不知道该如何设置 我尝试过
Set-Alias -Name pmsp -Value "pnpm store prune" Set-Alias pmsp "pnpm store prune" Set-Alias pmsp pnpm store prune 以上都不行,要么直接打开终端就报错, 要么执行 pmsp 的时候提示无法将“pnpm store prune”项识别为 cmdlet 、函数、脚本文件或可运行程序的名称
求大佬指教一下
]]>请问 v 友,有方法确认终端输出是 stdout 还是 stderr 吗?或确定终端输出的 stream 号?
]]>
若关闭网络,则需要 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 ]]>Get-ChildItem *.txt | Rename-Item -NewName { $_.Name -replace '.txt','.log' } 无法理解 Get-ChildItem 获取的文件后,通过管道,具体是使用哪种方式传递给 Rename-Item ,以及传递了什么内容。
上面代码我的理解,Get-ChildItem 命令的结果通过管道传递给了 Rename-Item 的 Path 参数。但 Path 只接受 string 。如果管道是 ByValue 方式,传递的应该是 Object ,所以不是 ByValue 。如果是 ByPropertyName ,Get-ChildItem 获取的 FileInfo 对象并没有 Path 属性,理论上也无法传递。
]]>
]]>我个人是在 Windows 端使用,23 年 9 月会 使用 Linux 和黑苹果,所以 ,不受系统的限制 个人目前 是 借助 CodeWars 这个刷题网站来练习 PowerShell 脚本编写;感觉 和用 C#编写方法函数差不多
现在学习有些吃力,想通过 脚本竞赛、编程挑战网站、外包运维需求等 方式,上手实践练习一番 ; 所以,我想请教一下 通过业务场景或者 需求 来驱动 练习 PowerShell 的方式有哪些? 个人知道 Windows 运维 多少需要学一下 PowerShell 的; 如有** 路过的运维师,可否指点一下 PowerShell 的学习,可以的话,真心感谢** pS:PowerShell 传教士的群,我加入,确实吸收不错的内容;
]]>我没有 google 到类似的问题, 请问有类似情况的朋友吗?
我的环境是原版 windows10, 保持着更新. version 21h2(build 19044.1889)
echo TEST 运行结果只有一个 TEST
请问如何让 echo TEST 同时显示出来?
]]>pwsh:powershell7.15; powershell: powershellv1.0,不知道啥版本,就 win11 自带的 : oh-my-posh+posh-git两个模块,启动速度 1000ms-1100ms$profile内容全部注释掉,启动速度,启动速度 500mspwsh -noprofile有明显停顿感(但感觉应该没 500ms 这么夸张了)powershell -noprofile几乎没有延迟这个延迟太高了,不知道有什么优化方法没,stackoverflow上提到.net 框架升级,感觉不怎么靠谱,因为powershell -noprofile这个指令基本没啥延迟,所以感觉应该是配置文件优化的问题,有 v 友懂如何优化吗
]]>希望能有比较详细的教学,谢谢。
]]>楼倚霜树外,镜天无一毫。 南山与秋色,气势两相高。 -(唐)杜牧
北京时间 2020 年 10 月 20 日:领先的 CMS 与 web 内核服务商、中国唯一具备 CMS 与字库图库全 web 呈现自主知识产权、alexa 排名第一的中文 CMS 厂商--上海 Zoomla!逐浪软件团队宣布,发布最新一代 CMS 产品:Zoomla!逐浪 CMS v8.2.0 。
这是继逐浪 CMS V8.1.x 之后的全新一代产品,我们为此启用了全新的版本号, 即:v8.2.x 系列。



.className{{你的样式}}生成静态目录值为空时,则不显示到静态目录的按钮。Areas/User/Views/Content/MyMDPic.cshtml Areas/User/Views/Content/AddMDPic.cshtml 前台访问路径:/User/Content/MyMDPic?NodeID=绑定图库模型节点 ID

/API/WXMP/LoginByWX?state=URLSignalR组件,部署在 IIS 环境中需要开启WebSocket Protocol服务/User/Pub/Pub_Edit?pubid=9&id=12截取字符串-@符,从而兼容取 josn 格式,如:中国,上海,浦东,可取值。原截取字符串更名截取字符串-逗号符,基于,号区隔参数。http://127.0.0.1:7777运行站点。/pages/api/wxapp.cshtml移动接口优化备注,完善写作语法。/pages/api/wxapp.cshtmlMarkdown 调用接口。windows 上是没有 gzip 命令的。
首先安装 scoop install gzip
压缩命令一般这么写 cat script.ps1|gzip >script.gz
这个写法在 bash zsh 和 cmd 都能正常工作,但是 pwsh 不行,甚至 powershell 5 也不行。
我知道 ps 管道可以传 PS-Object,但不会不会兼容文件流吧,目前还没找到说这个问题的,先在这分享一下继续寻找 解决方案。
]]>Talk is cheap!
https://paste.ubuntu.com/p/3dRsf4krbb/ (Expired in a week)

语法错误不要说出来,比如a、an。。。给个面子哦🙈
]]>PSReadLine 是 PowerShell 的官方模块,为 PowerShell 提供了缺失的交互特性。例如像 zsh/fish 那样的交互式的补全、语法高亮、emacs 按键模式等等。有了 PSReadLIne 之后的 PowerShell 才终于像点样了。
安装(详见官方项目 README):
Install-Module PSReadLine 安装之后,PSReadLine 的一些特性并不会自动启用,可以在 PowerShell 的 profile 配置文件里自己按需配置。但是自己从头搞毕竟很烦,直接白嫖官方提供的配置样例就可以,已经非常好用了。
posh-git 可以为 PowerShell 提供 git 命令补全。oh-my-posh 可以美化 prompt,提供各种主题。直接把两个一起安上:
Install-Module posh-git -Scope CurrentUser Install-Module oh-my-posh -Scope CurrentUser 在 profile 配置文件中启用模块并选择 prompt 样式主题:
Import-Module posh-git Import-Module oh-my-posh Set-Theme Powerlevel10k-Lean 主要是配置字体和配色方案。配色方案可以在 iTerm2-Color-Schemes 这个项目中挑选。个人比较喜欢 Gruvbox Dark 配色。

在 Windows Terminal 配置文件中加入 Gruvbox Dark 配色方案。
"schemes": [ { "name": "Gruvbox Dark", "black": "#1e1e1e", "red": "#be0f17", "green": "#868715", "yellow": "#cc881a", "blue": "#377375", "purple": "#a04b73", "cyan": "#578e57", "white": "#978771", "brightBlack": "#7f7061", "brightRed": "#f73028", "brightGreen": "#aab01e", "brightYellow": "#f7b125", "brightBlue": "#719586", "brightPurple": "#c77089", "brightCyan": "#7db669", "brightWhite": "#e6d4a3", "background": "#1e1e1e", "foreground": "#e6d4a3" } ] 在 PowerShell 的 profile 部分选择 Gruvbox Dark 作为配色方案。同时做一些其他调整(因为 Windows Terminal 支持字体 ligature,所以选择了 Fira Code 字体):
{ // Make changes here to the powershell.exe profile "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", "name": "Windows PowerShell", "commandline": "powershell.exe", "hidden": false, "fontFace": "Fira Code", "fontSize": 11, "colorScheme": "Gruvbox Dark", "cursorShape": "vintage" } 
本来打算直接拿来用的, 看这老哥的用法我就直接懵逼了 
翻了下脚本代码, 这个方法在脚本里面, 可怎么直接调用起来的? powershell 菜鸡一枚, 来请教下大佬
]]>在对 PowerShell 7.0 RC1 的所有已合并 PR 分类后,我们已经决定拟在下周发布个 RC2。GA 有望在二月早期发布。
你鸽你有理

站在产品的角度来说,也算是个好事吧。
]]>PowerShell 7.0 对广大 Windows 平台的 PowerShell 用户来说,最惊艳的莫过于 Out-GridView 命令的回归,同时 Joey 也列了一些功能卖点:
]]>
- .NET Core 3.1 (LTS)
ForEach-Object -Parallel- Windows compatibility wrapper
- New version notification
- New error view and
Get-Errorcmdlet- Pipeline chain operators (
&&and||)- Ternary operator (
a ? b : c)- Null assignment and coalescing operators (
??and??=)- Cross-platform
Invoke-DscResource(experimental)Out-GridView,-ShowWindowand other legacy GUI cmdlets are back on Windows- A ton of awesome quality-of-life improvements too numerous to list out here
移动的文件夹,与目标文件夹有相同文件名的文件,如何强行覆盖?
]]>现在问题是,如何删除一个已经导入进去的 IIS 证书,比如 IIS 证书名是:Name, 有无方法,用命令行或 PowerShell 来删除它。
网上找到的方法是采用 CertUtil [选项] -delstore CertificateStoreName CertId 来删除,但无法读到 CertificateStoreName 与 CertId,也就没有办法了,请求协助。
]]>如何用 powershell 将他导到另一台服务器上呢? 因为操作系统是 windows core 模式,没有视窗界面,然后卡在这上面了,呜呜,求大佬帮忙。
]]>上面命令,仅能对文件夹中的文件起作用,文件夹本身不起作用,请问有什么语法,支持直接操作文件夹权限的吗?
希望哪位大哥相助:)
]]>这个项目看上去气势磅礴,值得关注。
]]>Out-GridView 通过GraphicalTools 模块在全部支持 PowerShell Core 的平台上登场了。如果要使用,运行以下 cmdlet 安装:
Install-Module Microsoft.PowerShell.GraphicalTools 更多信息请访问微软开发者博客:Out-GridView Returns
]]>需要先安装 PSSQLite 模块,具体可以参考用 PowerShell 玩转 SQLite 数据库
Import-Module PSSQLite $ent_codes_db = "D:\Scripts\DB\ent_codes.sqlite" $query = "INSERT INTO ent_codes VALUES (@name, @code, @regday, @character, @legalr, @capital, @bscope, @prov, @city, @addr)" Get-ChildItem D:\Downloads\json\ -Recurse -File | % { (Get-Content $_.fullname | ConvertFrom-Json).erDataList | % { $name = $_.name $code = $_.code $regday = $_.registrationDay $character = $_.character $legalr = $_.legalRepresentative $capital = $_.capital $bscope = $_.businessScope $prov = $_.province $city = $_.city $addr = $_.address Invoke-SqliteQuery -DataSource $ent_codes_db -Query $query -SqlParameters @{ name = $name code = $code regday = $regday character = $character legalr = $legalr capital = $capital bscope = $bscope prov = $prov city = $city addr = $addr } } } ]]>