0
1

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.

WindowsのExplorerを開いているフォルダーでWindows Terminalを起動する

Last updated at Posted at 2022-11-19

TL;DR

WindowsのExplorerを開いているフォルダーでコマンドを叩きたいとき、Windows Terminalをそのフォルダーで起動する簡単な方法を見つけたので紹介するよ。

背景

むかし、インフラエンジニア界隈の友人に「Explorerのアドレスバーにcmdって入力するとそのフォルダーでコマンドプロンプトが開くよ」って教えてもらってもらった。
あまりに便利なのでずっと使っていたのだけれど(pwsh.exeでもできた)、最近Windows Terminalを使うようになってからこれができないことが判明、ちょっと試行錯誤したらできたので共有する、というもの。

期待する動作

※PowerShell Core(pwsh.exe)がインストールされている前提での再現です。

  1. Explorerのアドレスバーにpwshと入れてエンター
  2. pwshがそのフォルダーで開く (Good)

image.png

Windows Terminalでの、実際の動作

※Windows Terminalがインストールされている前提での再現です。

  1. Explorerのアドレスバーにwtと入れてエンター
  2. Windows Terminalが別のフォルダーで開く (Better to fix)

image.png

対策

詳細は後述することとして、以下の通りにすると期待した動作になる。

設定を開く

image.png

設定を変える

「既定値」> 「開始ディレクトリ」を.にして、保存する。

image.png

ためす

wtと打ってEnter

image.png

できた

image.png

なんでこれでいいのか?

よくわからないけど、Windows Terminalのドキュメント-dオプションが紹介されていることと、Windows Terminalのデフォルト設定に%USERPROFILE%が既定値だとあることとの情報があった。
それで、この設定変えてみようと思ったら%USERPROFILE%ってフィルインされてたので、多分この設定値は-dの引数なんだろうなーと思い、試したら期待した動作となりました、という次第です。

参考URL

0
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?