LoginSignup
1

More than 5 years have passed since last update.

WSL bashでファイル(フォルダ)をnotepad.exeで開く方法

Posted at

久々のQiita投稿です。淫夢記事しか投稿してないのはまずいかなと思ってまともな記事を1つシェアさせていただこうかと思いました。

今回は、Windows 10のWSL bashでファイルをnotepad.exeとして開く方法になります。もちろん、notepad.exeじゃなくても開けます。atomでもsublでも。やり方は同じです。

以前僕のブログで紹介した方法とほとんど同じ内容というか簡易版なんですけど、簡潔な分分かりやすいかと。

WSLのbashからWindowsの実行ファイルを実行する | yuipro

手順


# # notepadの位置を確認
$ which notepad.exe
/mnt/c/Windows/System32/notepad.exe

# # ファイルと中身を作成
$ cat > _tmp.txt
hoge

# # これでもいいんですが…
$ realpath _tmp.txt
/home/yuis/lib/_tmp.txt

# # WindowsならEverythingという便利ツールがあります。Everythingで_tmp.txtを検索して、出来てた結果をctrl+shift+Cでフルパスをコピーすることが可能です。# => C:\Users\ifgm2\AppData\Local\lxss\home\yuis\lib\_tmp.txt

# # こうじゃなくて…
cmd.exe /C "/mnt/c/Windows/System32/notepad.exe" '/mnt/c/Users/ifgm2/AppData/Local/lxss/home/yuis/lib/_tmp.txt'

# # こう。/mnt/ => C: へ変更するのを忘れずに。
cmd.exe /C "C:/Windows/System32/notepad.exe" "C:/Users/ifgm2/AppData/Local/lxss/home/yuis/lib/_tmp.txt"

https://yuis.xsrv.jp/images/ss/ShareX_ScreenShot_4f717632-b91a-4142-8594-b998339734c0.png

蛇足

わぁいalias あかりalias大好き。


# # aliasしておくと便利だよ。
# ## notepad
alias execnotepad='cmd.exe /C "C:/Windows/System32/notepad.exe"'
execnotepad "C:/Users/ifgm2/AppData/Local/lxss/home/yuis/lib/_tmp.txt"

# ## atom (せっかく書いたのでコードの参考程度にどうぞ)
alias execatom='$(cmd.exe /C "C:/Users/$(cmd.exe /c "echo %USERNAME%" | sed -e 's/\s//g')/AppData/Local/atom/bin/atom")'
execatom "C:/Users/ifgm2/AppData/Local/lxss/home/yuis/lib/_tmp.txt"
bash: C:/Users/ifgm2/AppData/Local/lxss/home/yuis/lib/_tmp.txt: そのようなファイルやディレクトリはありません
# oh.. aliasだと無理っぽかった

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