Change command prompt to only show current directory name

I was fiddling around with the prompt commando in cmd and was wondering whether there was a way to show the path like C:\..\dir4 instead of C:\dir1\dir2\dir3\dir4.

I have searched around, and I can only find the most simple methods, like using prompt $g to change it to a > or prompt $p$_ to make it new line.

Is it in any way possible?


With the standard command interpreter, what you are asking for is not possible.

This is the set of escape sequences supported by cmd.exe on Windows 8.1, most of which date back to comparatively ancient versions of MS-DOS:

$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)

There is also $+ (PUSHD stack depth) and $M (remote name for mapped drives), which don't apply to your situation.

The list of escape sequences supported on your particular system can be displayed by executing the command HELP PROMPT.

However, you can probably use PowerShell, which has a far more capable prompt subsystem. This however uses a different command interpreter than cmd.exe.