Prompt does not support listing only the current folder, nor does prompt support querying environmental variables.
So even though the following command is possible, it does not work as desired:
The above command will show the right 20 characters of the path, and would appear to be the best solution... except, when you change path, the string stays exactly the same.
So that doesn't work. Prompt does not have other options to specify just the last folder in a path.
But the reason most people want this, is because on a long path, the cursor starts at the very end of the screen which makes typing commands a bit hard.
There are a few solutions to work with this problem.
- Don't use long paths, and if you have to, create junctions so you can create a shortcut to a lower path, so the path itself becomes shorter.
For example, you have C:\Program Files (x86)\Microsoft Office\Office16\Root and you want to have this folder accessible as a short path, you could do the following:
cd /d c:\links
mkdir /j "C:\Program Files(x86)\Microsoft Office\Office16\Root" Office
Administrative rights on the command prompt are required to create symbolic links.
If you now go to c:\links\office, you end up on the office folder, but on your harddisk the files remain on the original folder.
- Increase the size of your command prompt window.
You can just increase the command prompt window in amount of colums and rows and more will fit on your screen, including longer paths.
- Alter the prompt to place the cursor on the next row. No matter how long the path is, your cursor always ends up at the same spot, so typing commands will not have interference of the long path.
You could write your prompt as follows:
Once you are happy with the changes of the command prompt, you can commit your changes by typing the following:
setx prompt %prompt%