Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Lounger
    Join Date
    Aug 2002
    Location
    Boise, Idaho, USA
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    XP Command Line Prompt

    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., Cocuments 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?

  2. #2
    Administrator
    Join Date
    Mar 2001
    Location
    St Louis, Missouri, USA
    Posts
    23,577
    Thanks
    5
    Thanked 1,057 Times in 926 Posts

    Re: XP Command Line Prompt

    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

  3. #3
    Silver Lounger Bruce K's Avatar
    Join Date
    Apr 2002
    Location
    Phoenix, Arizona, USA
    Posts
    1,876
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: XP Command Line Prompt

    Hi, Mike ~

    You can simply

    <code>cd C:</code>

  4. #4
    Plutonium Lounger
    Join Date
    Oct 2001
    Location
    Lexington, Kentucky, USA
    Posts
    12,107
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: XP Command Line Prompt

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

  5. #5
    Lounger
    Join Date
    Aug 2002
    Location
    Boise, Idaho, USA
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: XP Command Line Prompt

    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

  6. #6
    Lounger
    Join Date
    Aug 2002
    Location
    Boise, Idaho, USA
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: XP Command Line Prompt

    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.

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: XP Command Line Prompt

    <P ID="edit" class=small>(Edited by jscher2000 on 08-Jul-04 22:14. Here's the VBScript file)</P>For a path that does not contain spaces (!!!) you can use

    <code>
    subst w: % CD%</code>
    [i]

  8. #8
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: XP Command Line Prompt

    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
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  9. #9
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: XP Command Line Prompt

    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
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  10. #10
    Lounger
    Join Date
    Aug 2002
    Location
    Boise, Idaho, USA
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: XP Command Line Prompt

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

  11. #11
    Lounger
    Join Date
    Aug 2002
    Location
    Boise, Idaho, USA
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: XP Command Line Prompt

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

  12. #12
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: XP Command Line Prompt

    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.

  13. #13
    Lounger
    Join Date
    Aug 2002
    Location
    Boise, Idaho, USA
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: XP Command Line Prompt

    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?

  14. #14
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: XP Command Line Prompt

    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

  15. #15
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: XP Command Line Prompt

    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"
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •