No, this isn?t about PowerShell. This is about the old Windows command line. You know, the one your dad uses. And me, too.
Here?s how I set mine up.
My Own bin
I create a c:\tools\bin folder. This is where I keep all the custom stuff I want in my path. Stuff that I put in here is just my own little smattering of command line tools, command files, etc.
MyCommandPrompt.cmd
Inside that bin folder I create a command file, MyCommandPrompt.cmd. This is actually the entry point to my command line. From inside this file, I will invoke my own cmd.exe call, but I will invoke a bunch of other stuff to set it up before I do.
@call "%VS110COMNTOOLS%\VsDevCmd.bat"
prompt $g
title Just what do you think you are doing, Dave?
color 8e
PATH=%PATH%;c:\tools\bin;
cd c:\projects\
cls
The first line in this file calls another file that comes with VS2012. The variable resolves as:
Go check out the file that calls, it is your developer command line and contains some things that will help you see how VS and the .NET frameworks sit on your machine. I will leave it to you to dissect the rest of those lines, but suffice to say they give me a command line that has some fun in it.
My Shortcut
I then create a shortcut in my bin folder that calls MyCommandPrompot.cmd. I do this because I want to customize some of the attributes of the shortcut calling the command file. For example, I want an elevated permission prompt, I want to run this all as admin.
Inside the shortcut, the Target value is:
%comspec% /k C:\tools\bin\MyCommandPrompt.cmd
And I can still set up all the other command line options I like for my command line. Buffer size, font, window size and position, etc.
Finally, I launch the shortcut and pin it to my taskbar. Now when I launch my command line I get the following.
What do you do with your command line environment?
I’ve seen people use Dropbox/Skydrive to sync a personal bin directory that’s in path across multiple machines. Could be very handy, although it’s got that “. in $PATH” ring to it.
Thanks, really nice tip. I decided to combine this with Console2 (
http://www.hanselman.com/blog/Console2ABetterWindowsCommandPrompt.aspx) so that rather than create a shortcut as you describe, I can enter the ‘Target value’ you use for your shortcut into File | Edit | Settings | Console | Shell instead.
Best of both 🙂
That is a very cool idea. Seriously cool.
Tangentially related is the shortcut I didn’t know about for a long time and use frequently now. If I need to run a command line app in a directory (say, to add args to the command line), I find opening cmd window and then navigating down to it a pain. A cool shortcut is to navigate to it in windows explorer and then click in the nav bar and type cmd and return. It’ll open a cmd window right there for you.
That is AMAZING!. Thanks for sharing.
That is awesome. New to me as well.
The same can be done by Shift-Right-Clicking on a folder and pressing “Open command window here”