Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've used the Bash shell on Linux for years and I'm very fast with it. By frequently appealing for autocomplete by hitting the tab key, I'm able to write long commands in few keystrokes.

Recently at my job I've started using the Windows Command Prompt and Cmd. I'm very slow in Cmd. It has an autocomplete feature, but it works differently. I think I understand how it works, but I don't understand how to use it effectively, in fact it often slows me down. So I ask, how to use how to use Cmd's autocomplete effectively?


Let me give an example. First I'll describe how I use Bash, then how I try to use Cmd, and what goes wrong.

Suppose the folders in the current directory have names made from a continent and a country, eg. africa-nigeria, asia-india, europe-france, and that I want to change folder to europe-norway.

The way Bash's autocomplete works is that the tab key expands only if there is a unique expansion. Otherwise, nothing happens, but you can press tab a second time to list possible expansions.

So to move to Norway in Bash, I type cd and then make the following keystrokes:

  1. e tab for europe-
  2. n tab (nothing happens)
  3. tab again. It lists europe-netherlands and europe-norway as potential expansions.
  4. o tab for europe-norway.

Great! Thanks Bash.

However, when I try the same keys in Cmd, it expands e tab to europe-albania, which happens to be the first folder beginning 'e', but isn't the folder I wanted! What should I do now—is it possible to make Albania into Norway? Or must I cancel the command with Escape and type everything from scratch?

share|improve this question

migrated from stackoverflow.com Apr 17 '13 at 12:13

This question came from our site for professional and enthusiast programmers.

    
Can you use a menu, eg. batch menu? –  Endoro Apr 15 '13 at 15:11
    
At the moment Stephan's answer is correct for you. Just type the cd e and then press the TAB key. What Windows is doing here it start sorting the folders in alphabetical order in words. As If there is Europe-albania before europe-norway, just keep pressing the TAB key continuously until you don't get your desired directory. –  avirk Apr 20 '13 at 1:26
1  
@Avirk, so the quickest way from Albania to Norway is to press the tab key 27 times? –  Colonel Panic Apr 23 '13 at 15:07
add comment

4 Answers

Hitting the TAB key toggles through all existent directories.

Try to enter just cd then TAB for a few times and you will see the principle.

cd countries/europe-s[TAB][TAB] 

for example will bring you to the second match (countries/europe-serbia)

share|improve this answer
add comment

Cygwin will allow you to run a Bash shell (apart from many other POSIX environment software) under Windows.

Otherwise, you might try an alternative shell, rather than than the ancient Command Prompt, to find one that best fits your needs.

Here is a list of some consoles that emulate bash on Windows :

win-bash
Road Bash
Git Bash described in this article

Other consoles :

Microsoft's Windows PowerShell and its wikipedia article (the most powerful)
Console with an article
ColorConsole
PowerCmd
GS.EXE
PyCmd

[EDIT] I have since discovered Cmder which is an excellent tabular console replacement that also brings with it much of the Linux shell behavior as well as a port of many Linux file-handling applications such as grep.

share|improve this answer
3  
+1. Cmd has always been a pathetic excuse for a shell, and Microsoft long ago gave up any development of it. Since you're already performant in bash, your best option will be to continue to use it by installing Cygwin. –  Andrew Schulman Apr 20 '13 at 11:06
1  
of course, PowerShell is the best on that list ;) –  Taylor Gibb Apr 24 '13 at 9:50
    
To complete the list a bit more: There was also 4DOS or better 4NT, both rather popular in former times and much more powerful than command.com or cmd.exe. It seems that Take Command (jpsoft.com/take-command-windows-scripting.html) is their successor. However I never used that one personally (and it's commercial). –  mpy Apr 24 '13 at 13:00
add comment

Bash in linux attempts to match and autofill all the first characters that are common to all files.

The windows command prompt, on the other hand just autofills the command prompt with the first element that matches.

e.g.: In linux bash: After typing cd countries\eTAB, bash will go upto countries\europe- since it matches all the filenames that start with e, and then you can enter the next few characters and press TAB again.

In Windows command prompt: After typing cd countries\eTAB, the command prompt will match the first possible filename that starts with e, europe-albania in your case, but it still remembers that you had only entered an 'e'. So if you press TAB again, it will show the next possible match (alphabetical order), europe-andorra.

If you want to get to europe-norway quicker, you could either:

  1. Type europe-no and then press TAB or
  2. Type e TAB and then keep pressing Backspace to remove the non-matching characters from the autofilled europe-albania upto the point where you reach europe- and then type 'no' again and press TAB
share|improve this answer
add comment
up vote 2 down vote accepted

1 year update: I came to the conclusion that Cmd's autocomplete is unusable, and stopped using it.

I installed Clink which gets you Bash-like autocompletion in Cmd.

Clink combines the native Windows shell cmd.exe with the powerful command line editing features of the GNU Readline library, which provides rich completion, history, and line-editing capabilities

It's brilliant.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.