How can I shorten the path of a DOS prompt?

前端 未结 4 752
春和景丽
春和景丽 2020-12-23 10:21

My path on my DOS prompt is ridiculously long. How can I shorten this?

C:\\RUBY\\Ruby_Practice\\prep-work-master\\coding-test-2\\practice-problems\\spec>
         


        
相关标签:
4条回答
  • 2020-12-23 10:33

    Right-click on My Computer|Properties. Then from the Advanced Tab, click Environment Variables, then add a new User Variable called PROMPT and set it to $p$_$+$g.

    http://www.hanselman.com/blog/ABetterPROMPTForCMDEXEOrCoolPromptEnvironmentVariablesAndANiceTransparentMultiprompt.aspx

    0 讨论(0)
  • 2020-12-23 10:43

    To remove the path from the prompt use 'prompt $g' which will just show the chevron. You can then use the 'cd' command anytime to see the directory you are in. E.g.

    C:\Windows\System32\drivers\etc>prompt $g
    >
    >cd
    C:\Windows\System32\drivers\etc
    
    >
    
    0 讨论(0)
  • 2020-12-23 10:47

    In addition to the @Daniel's answer, if you want to go back to the normal state, You can type prompt (without any arguments) and press Enter

    It's not related to the question exactly, but i find it more useful to this scenario. When we use this prompt $G, this changes the command prompt path to >. Even when you navigate to the sub folders, the prompt will still remain as > which is not much useful.

    Rather than doing this, we can map the most used path to a virtual drive. like C:\Users\ram\Desktop\temp to a virtual drive X:. By this way, you need not to see the unneeded path, as well as you can see the sub folder navigations like X:\subfolder>.

    This is more useful to map your project to a virtual drive and do all the operations.

    To Map a path to a virtual Drive

    1) type subst [Drive:] [path] Example: cmd>subst X: C:\Users\ram\Desktop\temp

    2) Then go to the drive by typing X: and Enter

    To back to the earlier mode, you can just type the corresponding drive letter. In this case C: and Enter

    0 讨论(0)
  • 2020-12-23 10:48

    Here is a .bat file that displays the prompt with the final folder name in the current dir path.

    for %%* in (.) do set CurrDirName=%%~nx*
    echo %CurrDirName%
    prompt %CurrDirName% $G
    

    Lines 1 and 2 come from This answer to SuperUser: "How can I find the short path of a Windows directory/file?"

    0 讨论(0)
提交回复
热议问题