Linux – Open file with bash on Windows

bashlinuxvimwindows 10windows-subsystem-for-linux

I have neovim installed in the WSL. To access it, I open ConEmu, which is set up to use the WSL Bash by default as soon as it opens

On Windows there are often times where I want to make some quick edits to a file, and to do that I usually right click it and Open with… (whatever Windows installed program I need).

Is there a way to add neovim to the Open with menu so that when I need to edit a file it will open ConEmu, which will start Bash, start neovim and open the file for editing there?

It doesnt have to be tied to the Open with menu, anything that is a click away, or in some other contextual menu will be fine. The thing I want to avoid is having to manually open ConEmu/Bash/neovim and cd to the file as it defeats the purpose (speed)

I've seen similar questions (e.g. Adding Bash on Ubuntu on Windows 10 to Explorer Context Menu (Issues)) but this is about more than just adding Bash on Windows to a context menu, I'd like to be able to open a file with neovim as well

Best Answer

Add this alias to your bash/zsh profile

alias explorer='/mnt/c/Windows/explorer.exe'

Then you can open folders or files like so: explorer ./src/main or explorer logfile.txt

Related Question