First time here? Check out the site's "greatest hits" or read a post from the archives. Feel free to leave a comment or ask a question, and consider subscribing to the latest posts via RSS or e-mail. Thanks for visiting!
Do you Tweet? Follow me on Twitter @shanselman or learn how to use Twitter!
« List of the undocumented bugs that are f... | Main | Parsing my IIS Log Files with LogParser ... »

Prompt(s) along with PushD and PopD

Posted 2005-01-20 04:26 PM in ASP.NET.

Let this post serve as a reminder to me (and you if you don't use it all the time) that PUSHD and POPD are available in Windows.

Certainly TAB AutoCompletion is a goodness (it KILLS me when I have to watch someone, especially on stage, type long dirs and files one char at a time) and folks often forget that you can even do more tricky things like:

C:\TEMP>type my*.ofx (now PRESS TAB)

and get:

C:\TEMP>type myfiledata.ofx

but you can also

C:\TEMP>pushd .
C:\TEMP>cd "\Documents and Settings\shanselm\Desktop"
C:\Documents and Settings\shanselm\Desktop>popd
C:\TEMP>

Shawn Van Ness via Craig Andera make this tip even more useful when combined with their command PROMPT environment variable (Remember when "Customizing Your OS" consisted of 10-line long PROMPT statements in 4DOS? Ah, the good not-quite-old days.) From Craig's post:

$P$_$+$G

Which, when I set it via either the prompt command or the PROMPT environment variable, gives me a command line that looks like this:

C:\data\Projects\flexwiki\FlexWikiCore
++>

The plusses indicate that I'm two levels deep in pushd, and I like that the working directory appears on the line before, obliterating the problem of long paths making commands linewrap. Nice!

 What a nice series of tips for a random Thursday. Thanks guys!

Tracked by:
"More command line goodness from Scott H." (Paul's Imaginary Friend) [Trackback]
"PUSHD and POPD" (Niklas Nihl) [Trackback]
"top 10 Tools you didn't know you had " (Van Hammond Blog!) [Trackback]
"Customize your command prompt!" (David Mohundro) [Trackback]
"A better PROMPT for CMD.EXE or Cool Prompt Environment Variables and a nice tra... [Trackback]
"PUSHD reminder - it automatically maps network drives" (Scott Hanselman's Compu... [Trackback]


Thursday, January 20, 2005 5:30:06 PM (Pacific Standard Time, UTC-08:00)
Imagine if ---

Command Prompt had intellisense :).
We have a graphical command prompt.
If would be possible to write your own "prompt" plugins for it.
If this command prompt accepted a subset of VB.NET - no inheritance, just plain procedural code.
If it'd be possible to stream to and from files using < and > operators (like Unix).

Now that's a command prompt of 2005 !! :)
Friday, January 21, 2005 12:00:22 AM (Pacific Standard Time, UTC-08:00)
As a fellow cmd junky, I feel compelled to point out that "pushd somewhere\else" is equivalent to "pushd . && cd somewhere\else." Sorry for being nitpicky.

There are alot of unix tools at http://sourceforge.net/projects/gnuwin32/ that help making cmd'ing more fun. For example, there is an xargs for windows, GNU find, sed, grep, etc.

I sooo wish we had intellisense in the cmd shell, or at least a more powerful cmd shell like tcsh or bash. Idioms like "^old^new" to edit the previous cmd are dearly missed.
Friday, January 21, 2005 7:04:25 PM (Pacific Standard Time, UTC-08:00)
The other fantastic thing about pushd is that you can pushd to a UNC share it will automatically map a temporary drive and change to it, just like this:

pushd \\servername\sharename\directory

Also, in addition to gnuwin32 mentioned by Chris, UnxUtils is also worth a look.
Sunday, January 23, 2005 8:54:27 AM (Pacific Standard Time, UTC-08:00)
William - You Rock! I didn't know you could pushd a UNC path. Awesome!
Sunday, January 23, 2005 5:36:23 PM (Pacific Standard Time, UTC-08:00)
Type in path names for a command prompt? On stage? No, no, no.

Just have an Explorer window open to the directory that contains the directory or file you want in the command prompt. Then when you want the path, drag the directory or file you want and drop it in the command window. Voila, the name of the directory or file, conveniently bounded by quotes, will be there.

Billy
Tuesday, January 25, 2005 5:07:52 PM (Pacific Standard Time, UTC-08:00)
This works too,
C:\>cd wi*

C:\WINDOWS>
francisco lopez
Comments are closed.