LoginSignup
1
1

More than 1 year has passed since last update.

VScodeでもPowershellでコマンド履歴検索をしたい

Last updated at Posted at 2020-06-21

三行で

  1. :sparkles:VScodeでもPSReadlineが正常に動くようになりました
  2. :rotating_light: だけど、コマンド履歴検索はVScodeの他のキーバインドと競合しているため正常に動作しません
    3. :wrench: なんとかするにはkeybindings.jsonに設定を書き込めば良いらしい

設定はこちら

この設定を作成、もしくは追加します。stackoverflowに感謝

keybindings.json
// 既定値を上書きするには、このファイル内にキー バインドを挿入しますauto[]
[
    {
        "key": "ctrl+r",
        "command": "workbench.action.terminal.sendSequence",
        "when": "terminalFocus",
        "args": { "text": "\u0012" }
    }
]

これでコマンド履歴を検索出来ます

image.png
image.png
ちなみに、bashもこの設定で同じことが出来ました。

動作環境

❯ $PSVersionTable
Name                           Value          
----                           -----
PSVersion                      7.1.0-preview.3
PSEdition                      Core
GitCommitId                    7.1.0-preview.3
OS                             Microsoft Windows 10.0.19041                                                     
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}       
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

❯ Get-Module psreadline
ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.1.0      beta2      PSReadLine  

Visual Studio Code 1.46.1
ms-vscode.powershell-preview
1
1
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
1
1