DEV Community

Cover image for How to Open Files and File Explorer From the Command Line - Windows
Jamie McCarville πŸ‡¨πŸ‡¦
Jamie McCarville πŸ‡¨πŸ‡¦

Posted on • Edited on

How to Open Files and File Explorer From the Command Line - Windows

Terminal Upgrade

Last month I went down the rabbit hole setting up my terminal on my Windows laptop. I had been using Git bash for all of my git & Github work, but did not have much other experience with the command line and wanted to improve my skills and upgrade my tools. As a starting point I followed the free video series from Wes Bos called "Command Line Power User." The goal of the video series is to get you up and running using Zsh and oh-my-zsh. I also used the GitHub repo "CmderZSH" by Dylan Fontana to help with some of the nitty gritty of installing on Windows. I decided to go with the Powerline9k theme to add some customzation.

My Current Setup

I won't get into the process of setting it all up as the links above can help you with that. With that being said, here is my current setup:

  • Cygwin ("...provide functionality similar to Linux on Windows")
  • Mintty (default terminal emulator for Cygwin)
  • Cmder (console emulator)
  • Zsh (Z shell)
  • oh-my-zsh (framework for managing Zsh configuration)
  • Powerline9k theme

Opening Files and File Explorer

After spending (more than anticipated!) time setting it all up, there was still something that I was struggling to get working. In Wes' videos, he has examples of opening files in his code editor using the 'open' command. I could not get it to work for me and after trying a few different things unsuccessfully, I left it and came back to it later.

The Solution

After some searching, I came across the answer that I was looking for. In Windows, we have a similar command to 'open' and that is the 'explorer' command. Here are a few examples of the command in action.

Open a File Explorer

Open a File Explorer in Current Directory

Open a File with the Default Program

Open a File with VSCode

*different command but similar functionality

That concludes my first blog post since I started learning to code! I have benefited greatly from so many posts and articles and I am hoping that I will be able to give back by sharing what I am learning as I dig into JavaScript and work towards landing a full time remote dev job. Best of luck to everyone on their goals for 2019 and I hope to post again soon.

Top comments (2)

Collapse
 
papesch profile image
Rob Papesch • Edited

Good work, command line is a powerful and effective way to work. Soon you will be sick of pointing and clicking :)

A few suggestions:

  • bash might be a better option than zsh as it's far more commonly used.
  • instead of git bash, look into MSYS2 (git bash is an inferior subset)
  • instead of Cygwin, why not use WSL (windows subsystem for linux) and get a real linux environment. (PS: I use "wsltty" for a nicer terminal on the WSL)
Collapse
 
jamiemccarville profile image
Jamie McCarville πŸ‡¨πŸ‡¦

Thanks for your reply. I’m enjoying Zsh at the moment so I’m going to stick with it for now, but I will keep those other options in mind. WSL isn’t an option on my laptop, but once I upgrade, that’s definitely the way I’m going to go.