Command Recall (Up Arrow)
When using the console (or command line), little shortcuts can save you a lot of time. Here are some that will save you some time in the console (but not necessarily in Python).
The first is the up arrow. Use this to bring up the last command you typed in. Press up multiple times to keep bringing up more commands you entered previously.
[pic]
Autocompletion (Tab)
Whenever you type in a filename or folder name (like in a "cd" command) and you don't want to type out the whole thing, just type in the first few letters and hit tab. If there is only one file/folder that fits that name, it will automatically fill it in (with escapes (indicated by a backslash(\)) and/or quotation marks). If there's more than one, what happens next is determined by whether you are on Windows or Mac OS X. On Windows, it will start with the first match and cycle through the others as you continue to hit the tab key. In Mac OS X, a list will appear of all the matches. You'll have to enter more characters and hit tab again.
With a little practice, this one will save you a lot of time.
End of File (EOF) (Ctrl+Z (Windows) or Ctrl+D (Mac))
These are useful for exiting programs while they are running. EOF is used mostly for long sequences of input to let the program know that you're done entering things. If you ever need to exit and don't want to go through all the trouble of finding out how that particular console application exits, just hit the appropriate sequence (ctrl+Z in Windows; ctrl+D in Mac).
NOTE: Do not hit Ctrl+Z in the Mac Terminal. It will do something very different that's a bit complicated. It's not the end of the world, but it's beyond the scope of this blog entry.
Interrupt (Ctrl+C (Windows and Mac))
There will come a time (most likely) when you write a program that contains a loop, and you make a mistake that causes that loop to run forever. Your program is now running forever! What can you do? Hit ctrl+C. This will send an interrupt signal to your program (actually I think it sends it to Python) and tell it to quit. This one can really get you out of a jam.
Clear Screen Commands ("clear" (Mac) or "cls" (Windows))
Ever wanted to clear away everything that was on the screen and start at the top again? You can with the "clear" (Mac) or "cls" (Windows) command. On the Mac, the "clear" command doesn't actually get rid of what you've entered; you can still scroll up and see it.
No comments:
Post a Comment