Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When you open up a cmd window, the current directory is displayed on the same line as the line that you enter commands. For example:

C:\Users\JohnSmith> dir /s

I spend a lot of time in a very deeply nested path, and the current directory is so long that it's affecting my ability to enter/edit commands.

Is there any way that I can change the current directory from being displayed in my cmd sessions?

share|improve this question

migrated from May 28 '11 at 18:39

This question came from our site for professional and enthusiast programmers.

I suggest you using powershell instead, it's a better shell in windows :) – nXqd May 28 '11 at 22:24
possible duplicate of Stopping command prompt from showing current directory in windows XP? – JdeBP Nov 28 '11 at 20:15
up vote 0 down vote accepted

Here's the help for the prompt command:

PROMPT [text]

  text    Specifies a new command prompt.

Prompt can be made up of normal characters and the following special codes:

  $A   & (Ampersand)
  $B   | (pipe)
  $C   ( (Left parenthesis)
  $D   Current date
  $E   Escape code (ASCII code 27)
  $F   ) (Right parenthesis)
  $G   > (greater-than sign)
  $H   Backspace (erases previous character)
  $L   < (less-than sign)
  $N   Current drive
  $P   Current drive and path
  $Q   = (equal sign)
  $S     (space)
  $T   Current time
  $V   Windows version number
  $_   Carriage return and linefeed
  $$   $ (dollar sign)

If Command Extensions are enabled the PROMPT command supports
the following additional formatting characters:

  $+   zero or more plus sign (+) characters depending upon the
       depth of the PUSHD directory stack, one character for each
       level pushed.

  $M   Displays the remote name associated with the current drive
       letter or the empty string if current drive is not a network

If you want to change the prompt and make it persistent, make it into a persistent %PROMPT% environmental variable, like this:

setx PROMPT $G$S

Close and restart CMD to see the change.

share|improve this answer

Type 'prompt /?' to get help on formatting command prompt

share|improve this answer

The only ways i'm aware of to do what you want, would be to put a reference to bat file in this location of the registry HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun (this location is mentioned in cmd /?)

I suggest in the bat file, using subst to assign a drive letter to the long path.

And you can also change the current directory by doing like cd \blah in your bat file. or R: if you've made R point to your long directory. subst R:

C:\>subst P: "c:\documents and settings\administrator"



You could also do something like

prompt $g

as an alternative to the famous default prompt $p$g

but then you might forget what directory you're in. The subst idea looks like a good one. In the bat file referenced in that autorun registry location for the cmd prompt.

I think those are good ways but I don't really know of other ways..

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.