LoginSignup
9
7

More than 5 years have passed since last update.

PSReadLineでPSのキーバインドをBashみたいにする

Last updated at Posted at 2017-05-10

Powershellのキーバインドをbashみたいに変更

最近Poweshellを使う機会が増えたので、PSReadLineを使ってbashで慣れているキーバインドに変更をしてみました。

  • PSReadLineキーバインドの確認
     Get-PSReadlineKeyHandler

  • 変更したキーバインド

Key Function Description
Ctrl+u BackwardDeleteLine カーソル位置から行頭までのテキストを削除します
Ctrl+b BackwardChar カーソルを 1 文字前に戻します
Ctrl+f ForwardChar カーソルを 1 文字先に進めます
Ctrl+d DeleteChar カーソル位置の文字を削除します
Ctrl+h BackwardDeleteChar カーソルの前の文字を削除します
Ctrl+p HistorySearchBackward 履歴を逆方向に検索します
Ctrl+n HistorySearchForward 履歴を順方向に検索します
Ctrl+a BeginningOfLine カーソルを行頭に移動します
Ctrl+e EndOfLine カーソルを行末に移動します
  • 設定方法

Set-PSReadlineKeyHandler -Key 'Ctrl+u' -Function BackwardDeleteLine
Set-PSReadlineKeyHandler -Key 'Ctrl+b' -Function BackwardChar
Set-PSReadlineKeyHandler -Key 'Ctrl+f' -Function ForwardChar
Set-PSReadlineKeyHandler -Key 'Ctrl+d' -Function DeleteChar
Set-PSReadlineKeyHandler -Key 'Ctrl+h' -Function BackwardDeleteChar
Set-PSReadlineKeyHandler -Key 'Ctrl+p' -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key 'Ctrl+n' -Function HistorySearchForward
Set-PSReadlineKeyHandler -Key 'Ctrl+a' -Function BeginningOfLine
Set-PSReadlineKeyHandler -Key 'Ctrl+e' -Function EndOfLine

9
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
7