Windows – Is there any way to customize Windows command line’s Prompt

command linewindows

The windows command line prompt display the full path of the currently directory, which will be too long when I am deep into a directory, like:

V:\Runtimes\ProjectName\src\ToolsTest\JavaCrashExample\JavaCrash\main\ToolsTest\JavaCrashExample\JavaCrash>

Is their any way to customized this, so that I can just display the current directory's name?

Thanks.

Best Answer

You can use the prompt command, which changes the displayed prompt.
Type prompt /? and you will get this:

C:\>PROMPT /?
Changes the cmd.exe command prompt.

PROMPT [text]

    text    Specifies a new command prompt

Prompt can be made 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    = (Equals sign)
    $S      (Space)
    $T    Current time
    $V    Windows version
    $_    Carriage return and linefeed
    $$    $ (Dollar sign)

If command extensions are enabled, there are a few more options, but these are the relevant ones.

In case you were wondering, the default prompt is: prompt $P$G,
and a BASH style prompt is: prompt $$.

The one that I use when I'm working in long directories is prompt $G, which is simply '>'.

Although there is no way to display just the current folder, you can always use dir to display folder information, including the path

Related Question