PWD for cmd.exe?

For years I’ve mourned the loss of my favorite unix shell command, pwd.  I can’t count the number of times I had typed those three  simple letters into my xterm window.  After moving to a Windows environment over 10 years ago I started anew with commands like dir instead of ls, type instead of more (wait! more works!), findstr instead of grep, etc…

But no replacement for pwd.  No worries, the prompt for cmd is the current working directory by default.  But what if you change the prompt to the date and time, like I often do (prompt $D$S$T$G), to have a history of when you types which command. That leaves you with no way to tell the current directory.

But today, I learned about the cd env variable. Echo’ing %cd% prints the current directory.  Excited by this, I created the simple batch file:

@echo off
echo %cd%\

I named it pwd.cmd and placed it in my aliases directory.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: