• XP Command Line Prompt

    Author
    Topic
    #407112

    I recently upgraded to Windows XP at work, and noticed some nice new features in the new command box (cmd.exe). But the verbose directory structure makes the long default prompt really distracting!

    Of course, I could remove the directory from the prompt entirely, but I wish I could have my cake and eat it, too. I still like a little memory jog to help me keep track of where I am, especially after the ‘phone rings. I can think of several approaches that would be nice; does Windows XP support any of them (or an alternative)?

    1. Abbreviate the home directory (e.g., C:Documents and SettingsUser NameMy Documentsfolder becomes ~folder, like in unix c-shell)
    2. Limit the number of directory levels that display in the prompt (again, like unix csh)
    3. (more in keeping with the GUI philosophy) put the directory in the window title; but would it update if I change directory?

    Viewing 7 reply threads
    Author
    Replies
    • #849092

      Hi Mike,
      If you care to have a look at XP Command-line reference. Don’t know if it will help but there’s lots of information.

      Joe

      --Joe

      • #849100

        Yes, thanks. There is a lot of information there, but I hadn’t found anything that suggested an answer to my wish list. I’ll keep looking. I’m also perusing the references from the April Windows Command Processor – I want to learn it (SP1) thread, such as the Allenware tutorial (for Win9x) and Labmice

      • #849101

        Yes, thanks. There is a lot of information there, but I hadn’t found anything that suggested an answer to my wish list. I’ll keep looking. I’m also perusing the references from the April Windows Command Processor – I want to learn it (SP1) thread, such as the Allenware tutorial (for Win9x) and Labmice

    • #849093

      Hi Mike,
      If you care to have a look at XP Command-line reference. Don’t know if it will help but there’s lots of information.

      Joe

      --Joe

    • #849094

      Hi, Mike ~

      You can simply

      cd C:

    • #849095

      Hi, Mike ~

      You can simply

      cd C:

    • #849098

      You can also do what I did. I created a desktop shortcut as shown in the attachment.

      • #849104

        Bruce and BigAl,

        Thanks for the suggestion. However, (unless I am missing your point) while switching to the root directory would simplify the prompt, that would be at the cost of being able to work in different directories. Just setting the prompt to $g would be more practical.

        I’ve been working a fair amount in FreeBSD lately, and was just getting spoiled by the flexibility of the unix csh and sh shells. It may be that Windows can’t easily satisfy my wish list. My work in the command box under Windows is pretty limited, so this is a relatively minor issue.

        • #849206

          (Edited by jscher2000 on 08-Jul-04 22:14. Here’s the VBScript file)

          For a path that does not contain spaces (!!!) you can use


          subst w: % CD%

          • #849437

            I should have thought of SUBST. I presume that CD is an environment variable that you populated by manipulating the PROMPT command.

            • #849774

              CD is an environment variable that took forever to discover. It is built in and refers to the “current directory” — presumably for the command window from which the variable is used.

            • #849819

              Hey, that’s neat! The CD variable saves the gyrations with PROMPT that I’ve been using to accomplish the same thing. But I hadn’t seen it when looking with the SET command. How did you come across this variable? And is it new with XP?

            • #849868

              Mike

              The % cd% environment variable came in with the % date% and the %time% ones when we went to Command Extensions Version 2 (in Windows 2000). There may have been others, but it’s so long ago(!) that I’ve forgotten… (Remove the blank, as usual, after the first %). The CD, DATE and TIME internal commands have been around almost as long as I have, since MS-DOS 2.0 for the first!

              John

              PS Some references:
              Jerry Schulman’s Tip 3239
              Also the more lengthy “Frequently Asked Questions Regarding The Windows 2000 Command Processor”

            • #849869

              Mike

              The % cd% environment variable came in with the % date% and the %time% ones when we went to Command Extensions Version 2 (in Windows 2000). There may have been others, but it’s so long ago(!) that I’ve forgotten… (Remove the blank, as usual, after the first %). The CD, DATE and TIME internal commands have been around almost as long as I have, since MS-DOS 2.0 for the first!

              John

              PS Some references:
              Jerry Schulman’s Tip 3239
              Also the more lengthy “Frequently Asked Questions Regarding The Windows 2000 Command Processor”

            • #850287

              > How did you come across this variable?

              I don’t know. It didn’t happen during the first hour… during the first hour I was redirecting the output of the COMPACT command, which lists the current folder when run without pararmeters, to a text file, and reading that in using a TextStream object. Good thing there was a better kludge. grin

            • #853256

              Gentlemen,

              Thanks for the info. I skipped from Windows 98SE to XP, so I missed the new environment variables in Windows 2000. But I remember the CHDIR (aka CD) command from way back in MS-DOS 2.11, imported along with the concepts of directories and redirection from unix. I think the DATE and TIME commands were in MS-DOS one point something-or-other, but in those days, I was using CP/M3.0 on a Z80.

            • #853257

              Gentlemen,

              Thanks for the info. I skipped from Windows 98SE to XP, so I missed the new environment variables in Windows 2000. But I remember the CHDIR (aka CD) command from way back in MS-DOS 2.11, imported along with the concepts of directories and redirection from unix. I think the DATE and TIME commands were in MS-DOS one point something-or-other, but in those days, I was using CP/M3.0 on a Z80.

            • #850288

              > How did you come across this variable?

              I don’t know. It didn’t happen during the first hour… during the first hour I was redirecting the output of the COMPACT command, which lists the current folder when run without pararmeters, to a text file, and reading that in using a TextStream object. Good thing there was a better kludge. grin

            • #849820

              Hey, that’s neat! The CD variable saves the gyrations with PROMPT that I’ve been using to accomplish the same thing. But I hadn’t seen it when looking with the SET command. How did you come across this variable? And is it new with XP?

            • #849821

              I have a feeling that CD is an Internal Command, rather than an Environment Variable.

              If you type ECHO % CD% then there is no output (no space between % and C)
              If you type CD .. then you change default directory to the next level up and echo the new path
              If you type CD then the system echoes the current path

              StuartR

            • #849822

              I have a feeling that CD is an Internal Command, rather than an Environment Variable.

              If you type ECHO % CD% then there is no output (no space between % and C)
              If you type CD .. then you change default directory to the next level up and echo the new path
              If you type CD then the system echoes the current path

              StuartR

            • #849775

              CD is an environment variable that took forever to discover. It is built in and refers to the “current directory” — presumably for the command window from which the variable is used.

          • #849438

            I should have thought of SUBST. I presume that CD is an environment variable that you populated by manipulating the PROMPT command.

        • #849207

          (Edited by jscher2000 on 08-Jul-04 22:14. Here’s the VBScript file)

          For a path that does not contain spaces (!!!) you can use


          subst w: % CD%

      • #849105

        Bruce and BigAl,

        Thanks for the suggestion. However, (unless I am missing your point) while switching to the root directory would simplify the prompt, that would be at the cost of being able to work in different directories. Just setting the prompt to $g would be more practical.

        I’ve been working a fair amount in FreeBSD lately, and was just getting spoiled by the flexibility of the unix csh and sh shells. It may be that Windows can’t easily satisfy my wish list. My work in the command box under Windows is pretty limited, so this is a relatively minor issue.

    • #849099

      You can also do what I did. I created a desktop shortcut as shown in the attachment.

    • #849235

      Mike

      What an interesting question!

      However, I can’t think of an answer that will satisfy you…

      About the best I can do is
      start “% cd%” cmd /k (as in jefferson’s post, omit the space after the first % !)
      which starts a command prompt window with the current directory as the title. However, the current directory is the one at the time you started the window, and won’t change. You obviously know how to modify the command prompt so can remove the long string, which I agree is annoying.

      I will try to get someone to work on this from one of the Command Prompt newsgroups!

      John

    • #849244

      Mike

      Here’s what I got back from my BATch file guru…

      QUOTE
      Yes, I’ve seen similar questions posed previously but no, I haven’t seen any great solutions.

      In W2k/XP, you can automatically run a batch file whenever you open a Cmd window (see cmd /? and the description for autorun). You could use that or the Cmd /k approach you mentioned via a desktop shortcut.

      However, as you say, the problem with this is that the title/prompt is wrong when you change directory. My recollection is that you then need to run a batch/program to update the prompt/title whenever you change dir. I think there are 3 approaches:

      1. have a short name batch and run that after doing a CD to simply update the title or prompt to the current value. Not a great approach.

      2. created a batch file (say C.bat) and use that instead of the CD command. Similar to 1 but the batch invokes an actual CD command then changes the title or modifies the prompt to suit. I used to have a similar CD batch file enhancer called CCD for finding abbreviated path names but my fingers couldn’t get out of the habit of typing CD so I stopped using it.

      3. use DOSKEY macros to replace the CD command with the name of the batch file which then does the work as per 2.

      I haven’t played around with it but I think I’d use a combination of an autorun file to do the initial setup for the title/prompt and to load a DOSKEY macro to replace the CD command. The replacement CD batch command would then do the rest after the window has opened.
      UNQUOTE

      So no great solution here, either!

      John

      • #849439

        John, those are interesting ideas. I think I’ll play with them when I get a little time. Thanks.

      • #849440

        John, those are interesting ideas. I think I’ll play with them when I get a little time. Thanks.

    Viewing 7 reply threads
    Reply To: XP Command Line Prompt

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: