PowerShell 代码段拾贝

获取按键的ConsoleKey

PS> while($true){ [System.Console]::ReadKey($true) }

    KeyChar     Key    Modifiers
    -------     ---    ---------
          [    Oem4            0
          ]    Oem6            0  
          {    Oem4        Shift
          }    Oem6        Shift

reference

Module: PSReadLine 历史记录功能

开启

在 $Profile 中添加如下即可开启: 基于历史记录的代码补全 功能

Set-PSReadLineOption -PredictionSource History

有关此功能的介绍: Introduction by 0xdf hacks stuff

有关历史记录History文件重复行的讨论

ForwardSearchHistory issue with -HistoryNoDuplicates

历史记录文件位于: C:\Users\[User Name]\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt

目前的默认逻辑 (PSReadLine Version: 2.1.0) 是: 仅当两条相邻command相同时, 消除duplicate. 讨论见Add an option to remove only consecutive history duplicates

 

posted @ 2020-10-09 00:47  willison  阅读(154)  评论(0)    收藏  举报