4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

PowerShellでもCtrl+Dでexitしたい

Last updated at Posted at 2023-06-02

こんなことがあります

Windowsが開発機なのでWindows Terminalを使ってLinuxにSSHしているが、exitする時、LinuxはCtrl+Dで抜けられるのに、PowerShellではexitと打たないといけなくて、これが地味に面倒くさい。。。

これで解決

PowerShellのプロファイルに次の内容を記述すればOK!

Import-Module PSReadLine
Set-PSReadlineKeyHandler -Key Ctrl+D -Function DeleteCharOrExit

手順

  1. プロファイルを作成する
  2. プロファイルを編集して保存する
  3. PowerShellに入り直す

プロファイルを作成する

if (!(Test-Path -Path $PROFILE)) {
  New-Item -ItemType File -Path $PROFILE -Force
}

プロファイルを編集して保存する

次のコマンドでメモ帳が開きます。

notepad $PROFILE

次の内容を記述しますして保存します。

Import-Module PSReadLine
Set-PSReadlineKeyHandler -Key ctrl+d -Function DeleteCharOrExit

image.png

PowerShellに入り直す

exitしてPowerShellに入り直せば、Ctrl+Dでexitできるようになっています。

参考資料

4
3
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
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?