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 want to learn to use the command prompt better on Windows to have more control over what I do and just for the learning experience. The main annoyance I have right now is all of the typing. If I want to perform an operation on a file with a large path I'm sitting there typing it out for a minute at least, and if I make a mistake I have to press the up arrow key and scroll through the entire thing and find what I did wrong. Is there any tools to make this easier?

share|improve this question
2  
Tab completion! Any decent terminal will have it (and if it doesn't I'd question the capability of the terminal you're sitting at). –  new123456 May 4 '11 at 12:25

19 Answers 19

up vote 33 down vote accepted

If you intend to use the command prompt only under Windows, you could use Windows PowerShell, as it is easier to use than the initial command prompt, and copies some behavior from the *nix-like terminals. (It provides also a lot more functionalities, but at first, at least to me, it's an "easier command shell").

picture of powershell

Edit: Changed picture for a more "friendly" one.

share|improve this answer
3  
Yes, in this case maybe it's not really adapted. To me, as I knew *nix terminals before, this powershell helped me, as it also provides a lot of aliases(shortcuts) for usual *nix commands. Typically, "ls" works like "dir". In general, it's also more consistent for the "tab completion", in my opinion, compared to the original shell, which makes it easier to navigate. –  Gnoupi Sep 1 '09 at 5:19
1  
PowerShell really is the way to go. As a long time user of cmd.exe I can tell you that it's really limited. Once you want to do anything clever, you'll end up needing VBScript or something similar, so you'll have to learn that. Each command has its own syntax and they're rarely similar so you have to learn each one and can't guess easily. PowerShell is much more powerful and much more consistent so you can apply what you've learnt from one command to another. –  serialhobbyist Sep 1 '09 at 13:19
1  
Also, PowerShell has MUCH better (IMO) help text. Anyone ever tell you to read the cmdpages? –  Hello71 Jul 5 '10 at 1:18

You can use the Tab key to auto-complete file names. Although keep in mind you must first type enough of the file name to uniquely identify it or else you will have to shuffle through incorrect matches. For example, you have a folder with these files and it is your current directory that you're sitting in with cmd:

.
..
Su.exe
Sup.txt
SuperUser.COM

if you wanted to auto-complete SuperUser.COM, you would have to type supe then press Tab, since none of the other files start with those 4 characters. Note that if you had typed su and then pressed Tab, you could press Tab twice more to reach SuperUser.COM or you could type ShiftTab to go backwards through the list and get there.

Another trick is if you have the file in an explorer window, you can drag it into the cmd window and it will type the name out for you.

share|improve this answer
2  
This works great thank you, but when i am tabbing through files sometimes i pass over mine, is there a way to go backwards? –  Adam Sep 1 '09 at 5:11
13  
Yep, shift-tab :) –  John T Sep 1 '09 at 5:12
2  
Bonus fact: shift + <any key that cycles through tabs/windows> is always equivalent to reverse e.g. alt-tab -> alt-shift-tab. –  glenneroo Jan 20 '11 at 6:39

Pressing F7 will list the last executed commands.

cd \ to get back to the c: directory.

share|improve this answer
2  
Hmm, didn't know that. –  Gnoupi Sep 1 '09 at 5:38

I suggest that you use the command prompt.

I know, it seems facetious, but this is serious---if not instantly helpful---advice. There is a lot to know, and to absorb it deeply, you have to use it over and over again.

share|improve this answer
9  
Yes, he wants to, but he would like to know what he can do with it, I think. Because "bruteforcing" the available commands might take some time. –  Gnoupi Sep 1 '09 at 11:26

If Windows PowerShell is too overwhelming, there are also some cmd replacement shells:

And more can be found via google.

share|improve this answer

Often you can reduce your typing by being in the correct directory. You can open a command shell in the directory you see in an Explorer window by adding cmd.exe in the folder type associations.

(Tools - Folder Options - File Types - Folder - Advanced - New - cmd)

Then, when you select cmd by right-clicking on that folder the command window that opens will have as its current directory that of the folder you clicked on.

alt text

share|improve this answer
1  
for XP users, MS Power Toys for XP will provide this for you as well: microsoft.com/windowsxp/Downloads/powertoys/Xppowertoys.mspx –  akf Sep 5 '09 at 11:53

Here are some more tips and tricks in using the command prompt including:

"...drag n' drop files or folders from an explorer window into a command prompt; this inserts the quoted path as if you had manually pasted it..."

This is yet another way to reduce the amount of typing involved in long file paths.

share|improve this answer
3  
Now THAT's useful. I didn't know that one at all. –  EvilChookie Sep 1 '09 at 7:35
1  
Already had that in my original answer :P –  John T Sep 5 '09 at 5:40

If you're using XP (don't know about Vista) you can download a powertoy that adds an "Open command window here" menu entry to your explorer folder context menu.

Something else that I've found useful is to stop using the windows default paths for everything. They are just too hard to remember and the spaces can become a problem. Using something more like linux' directory structure can be a real time saver. My directories look something like this (by way of examples):

 - C:\usr\bin\firefox 
 - C:\usr\bin\7zip
 - C:\usr\bin\dropbox

 - C:\usr\lang\cpp\gcc
 - C:\usr\lang\cpp\lib\qt_4_5_0
 - C:\usr\lang\python\py25

 - C:\usr\home\wrksp\cpp
 - C:\usr\home\doc
 - C:\usr\home\wrksp\svn

Way easier to remember.

share|improve this answer
5  
Vista (Ultimate Edition at least) has this by default, but hidden from the average user. Just hold down shift and then right-click a folder in the right-hand Explorer pane, and you should see "Open Command Window Here". –  GAThrawn Sep 1 '09 at 9:06

Something I use constantly while using command prompt is the up arrow (and down arrow) to scroll through recently used commands. Especially when I've entered a long command and only wish to edit some part of it without retyping it.

A short example, if you:

c:\>ping 192.168.1.1

And then want to ping another similar address, you can simply press the up arrow. The command appears on the prompt with the cursor at the end. This makes it easy to backspace once and change the address to 192.168.1.2 or something similar.

share|improve this answer

You may find "Useful Command-line Commands on Windows" from Server Fault helpful. Actually, there are quite a few interesting command-line questions there, go have a look.

share|improve this answer

Personally I think that if you want to learn to use the Command Prompt and are not finding it joyful, you probably don't need to use the Command Prompt.

As soon as you need to hit a CLI, you will find it useful, and even pleasant. If you're trying to do your day-to-day tasks with it, then you're bashing your head against a wall.

Once you are familiar with the command prompt, you may migrate your day to day tasks there just because it's easier than always reaching for the mouse :)

share|improve this answer

Definitely grab a copy of Cygwin, and add its \bin folder to your PATH variable. It's like a usable command prompt!

But really, the only way to get used to it is to get used to it, so use it!

share|improve this answer

Here’s the complete list of function key actions :

F1 retypes the previous command one character at a time
F2 brings up a dialog and asks “Enter the char to copy up to:”
F3 retypes the last command in full
F4 brings up a dialog and asks “Enter char to delete up to:”
F5 as for F3
F6 Print EOF character (Ctrl+Z)
F7 brings up a dialog of all the recent command history
F8 brings up each of the most recent commands, one at a time
F9 brings up a dialog and asks “Enter command number:”
share|improve this answer
1  
Has any one got F4 to work? The dialog appears but doesn't delete. –  Charles Beattie Feb 4 '11 at 10:46

Install the Windows Explorer replacement Xplorer2. It includes a command prompt tool that allows all functions of the command prompt ALONG WITH the Windows GUI like use of the mouse, right-click for copy-paste functions etc. Take a look the screenshot below.

Command Prompt Screenshot

share|improve this answer

Make use of environment variables.

For example, instead of typing c:\documents and settings\username you can simply use %userprofile%. For a list of standard environment variables, type SET and press enter on a command prompt.

In addition, get familiar with commands that are available to you - I like two sites for them: www.ss64.com and www.robvanderwoude.com

You can also learn batch scripting - using that, you can automate frequently used tasks.

share|improve this answer

There are some great tips posted in this thread!

In my opinion posting CMD replacements is rather 'Off Topic'. But it seems to be OK here so I might add ColorConsole to the list.

The tabbed interface, Favorite Commands menu, Copy/Cut & Paste and indeed HTML export are very useful features that I don't want to miss anymore.

p.s.: try this in the "Must have Firefox addons" thread: Lads, get Opera, it's got the goodies aready built in! :)

share|improve this answer

Enable quick edit mode to:

  • Copy text by: select text + ENTER
  • Paste code by pressing right click.

enter image description here

I also change the Font and the layout to something more pleasant than the default bit map.

enter image description here

Finally add more rows and columns the the editing window, and more rows to the buffer.

enter image description here

Screenshots are in spanish, but they are exactly in the same place in english

share|improve this answer
1  
Changing the width of the console window is one of the first things I do on a new computer. –  Justin Oct 5 '09 at 11:05
  • To paste into a command window using the keyboard, press alt-space, e, p.
  • To repeat the last command that started with the letter "d" (for example; it could be any character) press d and then F8.

The latter tip may sound kind of obscure, but when you spend a lot of time in the console it can be much faster and easier than pressing the up arrow or F8 several times.

share|improve this answer

I agree with the suggestion to use powershell. In addition I find it incredibly useful to set up functions and aliases to reduce common tasks to fewer letters typed.

For example, to launch a http link I set this up in my powershell profile:

function browse-url { param($url="http://www.google.com/"); (new-object -com shell.application).ShellExecute($url); }
set-alias -name "browse" -value "browse-url"

and then I just type browse to open google, or browse http://.... to open a specific link

Another example for listing files or directories:

function lsa { param($path="."); Get-ChildItem -Force $path }
set-alias -name "la" -value "lsa"
set-alias -name "ll" -value "lsa"
function lsd { param($path="."); lsa $path | ? { $_.PSIsContainer } }
function lsf { param($path="."); lsa $path | ? { !$_.PSIsContainer } }
function lat { param($path="."); lsa $path | sort -property lastwritetime -descending }
function latr { param($path="."); lsa $path | sort -property lastwritetime }
function fi { param($pat,$root="."); gci -r $root | ? {$_.Name -match $pat} | % { $_.FullName } }

And then I use lsa to show all items in a directory, including hidden items. Use la or ll as even shorter aliases.

I use lsd to list only folders, lsf to list only files, lat to list ordered by last write time, and latr to list by time in the opposite direction.
fi was set up as a simple substitute for the unix find command, just recursively look for a file name.

share|improve this answer

Your Answer

 
discard

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