START making DOS follow your CMD
I’ll be the first to say, I have *major* terminal envy working with so many Linux and Mac developers. Not just the shell, but pretty much everything about the command line experience is better on *Nix. But don’t count the Windows console completely out just yet. Let’s look at a few commands that can make your life much better in the world of Command.com.
START it up
One of the biggest hurdles to going completely command-line on Windows is having to grab the mouse and click to open a new command prompt when you’re working, reseting all your environment variables and re-navigating to your working directory. Or if you just want to execute an application that will block on the command line during execution. Blech. But those are easy obstacles to surmount using the START and CMD commands.
-
Old Way (at least for me)
<Win>- type
CMD <ENTER>- >
cd c:\Where\Ever\I\Was\Just\Working - >
set PATH=c:\My\Libs;%PATH% - >
MyBlockingApplication.exe /arg1 /arg2
Ugh. Now multiply that by a hundred times a day. Despite having scripted out the environment configuration there still was a lot of context change, reaching for a mouse and clicking around. But using the START command I can save a lot of that mess.
-
New Way
- already in a command prompt with my PATH and in the working directory
- >
START MyBlockingApplication.exe /arg1 /arg2
So what did that do? START opens up a brand new command prompt, keeps the environment settings and working directory from the opener, then executes the statement passed to it. Very handy. You can even chain commands together to get some extra fun.
A more realistic example that I use for a good chunk of my day to day work is to start up the gem server to read some documentation. I don’t want to block my current command line, and I don’t want to go through those multiple steps just to start up a new command prompt.
> START /MIN /LOW gem server & chrome http://localhost:8808
It’s not as bad as it may seem. All I’ve done there is start up a new command prompt, running minimized with low priority. I told the command prompt to run the gem server and then start chrome for the appropriate url. The & symbol is used to chain together multiple commands and isn’t particular to START.
Now that you can start and execute command line programs in a separate window without blocking your session it’s a simple matter to open up multiple command prompts for you to work in as well.
> START CMD
This will bring up a brand new command window, all setup with your current working environment and ready for you to crank away.