Mac users have this magic convenience of typing open index.html into their terminal to open a file from their current directory in the browser. Those of us on WSL aren't so lucky. If you're lucky, the open command will open a windows directory. Cool, I guess? But not exactly super helpful. The internet abounds with recommendations --- from trying xdg-open, configuring your www-browser defaults, and setting your PATH environments to some even more convoluted methods. But the question remains: what's the easiest way to open an HTML file in the browser from WSL?
The closest thing I've found is to use the Windows Subsystem for Linux's explorer.exe command. Assuming you've set your browser environment variable in bash, then typing something lile explorer.exe index.html should open the file index.html in your default browser. If that works, congrags! That's the simplest version of Mac's open command. Well, sort of...
Typing explorer.exe is still a little bit of a handful, and I'm lazy. I mean open is four characters, and explorer.exe is twelve. That's three times as many characters. No thanks!
Wouldn't it be nice if we could do something simpler? How about see index.html? Fortunately, we can leverage the ability to create aliases in bash to make this dream a reality. Just drop the following three lines directly into your terminal:
export BROWSER='/mnt/c/Windows/explorer.exe'
echo "alias see='explorer.exe'" >> ~/.bashrc
source ~/.bash_profile
You're done! No need to play around in your config files. 🙌 Next time you need to open that index.html file, all you need to do is type see index.html and watch the magic happen. And it's one fewer character than those Mac folks. Just imagine what you could do with that kind of time savings...

Top comments (2)
This is helpful, but users should keep in mind the command will open up a directory if you're not in the same directory as the file you're looking for
For example:
see docs/index.htmlwill open up your file explorer and notindex.htmlOn Windows Machine
1.Go to Git Bash or Command prompt on windows.
2.Go to your directory path where the index.html is stored.
3.
Cd Your path till the directory where that index.html file is stored4.Simple Type
start index.htmlon your terminal of gitbash/command prompt5.WOHOHOHOHO Finally opened the file.
Thanks,
Hardik Gangani