Last active
November 15, 2021 05:25
-
-
Save nv-h/081684cee2505cd336e26c2660fc7541 to your computer and use it in GitHub Desktop.
Windows PowerShell Ctrl+R history with fzf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PowerShell Core7でもConsoleのデフォルトエンコーディングはsjisなので必要 | |
[System.Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding("utf-8") | |
[System.Console]::InputEncoding = [System.Text.Encoding]::GetEncoding("utf-8") | |
# git logなどのマルチバイト文字を表示させるため (絵文字含む) | |
$env:LESSCHARSET = "utf-8" | |
# 音を消す | |
Set-PSReadlineOption -BellStyle None | |
# 履歴検索 | |
Set-PSReadLineKeyHandler -Chord Ctrl+r -ScriptBlock { | |
# いつからかawkの表示がされないようになったので、以下コマンドを実行 | |
# Set-Alias awk C:\Users\saido\scoop\apps\msys2\current\usr\bin\awk.exe | |
$command = Get-Content (Get-PSReadlineOption).HistorySavePath | awk '!a[$0]++' | fzf --tac | |
[Microsoft.PowerShell.PSConsoleReadLine]::Insert($command) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment