5

I'm trying to figure out how to shorten the prompt in Windows 10 so I don't end up with a deeply nested directory path taking up most (or all) of the command line.

I've tried applying the information shown here, but it doesn't seem to translate correctly to Windows 10. I created a new environment variable named PROMPT and filled in the applicable info, but it doesn't seem to have the desired effect - it just moves the > down one line; still has the long path.

5
  • 1
    You haven't said what you would like the prompt to actually display. In any case, the possible options can be found here - prompt
    – DavidPostill
    Mar 5, 2016 at 15:04
  • Good point... I was more concerned with getting it to change, and stay changed - figured the specifics of what I want it to look like would be (somewhat) unique to my tastes. Basically I want it to abbreviate the directory path to just the drive letter, and the current working directory plus a > prompt.
    – memilanuk
    Mar 6, 2016 at 2:33
  • $n is the current drive. You cannot get the current directory only into the prompt. $g is >.
    – DavidPostill
    Mar 6, 2016 at 8:36
  • Consider using powershell. You can do pretty much anything you like. See Nice Powershell Prompt for one such example.
    – DavidPostill
    Mar 6, 2016 at 8:42
  • -1 You have done absolutely no experimentation at all. The answer you linked to WORKED that's what $p$_$g does it puts a new line before the >, so that you have a whole new line to type your commands on, while still being able to see the path. If you don't want to see the path then experiment and you'd see that you can remove the $p and then remove the $_ it's not a huge amount that you need to experiment with there. And any help regarding the prompt command will show you other options. And one of the things it mentions about permanently setting the prompt is what redgritty mentioned too
    – barlop
    Mar 6, 2016 at 11:37

1 Answer 1

8
C:\Program Files\Internet Explorer\en-US>PROMPT=$N$G$S

C> ver

Microsoft Windows [Version 10.0.10586]

C>

How do I make that stick?

Easy way

C> setx PROMPT $n$g$s

SUCCESS: Specified value was saved.

Then close and reopen command prompt.

Hard way

Win+Break, "Advanced System Settings", "Environment Variables" ...

enter image description here

enter image description here


Note:

The prompt text 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) 
   $M  Display the remote name for Network drives
   $N  Current drive 
   $P  Current drive and path 
   $Q  =           (equal sign) 
   $S              (space) 
   $T  Current time 
   $V  Windows NT version number 
   $_  Carriage return and linefeed 
   $$  $           (dollar sign)
   $+  Will display plus signs (+) one for each level of the PUSHD directory stack
4
  • Great! Now how to make that stick?
    – memilanuk
    Mar 6, 2016 at 2:32
  • @memilanuk: See updated answer, Mar 6, 2016 at 10:32
  • @memilanuk you wrote "how to make that stick?" <-- how about you look at the answer you pointed to in your question, which also spoke of setting an environment variable
    – barlop
    Mar 6, 2016 at 11:39
  • Probably worth citing your source: ss64.com/nt/prompt.html See also neat ways of combining this with this script.
    – ruffin
    Jun 12, 2023 at 19:52

You must log in to answer this question.

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