3

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?

2

3 Answers 3

1

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
       drive.

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.

1

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

0

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"

C:\>P:

P:\>

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..

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .