Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Fixing command-line typos before hitting enter UNIX
Quite by accident I just realized that pressing Option-S auto-corrects your commands in the Terminal. Type this in the Terminal:
 % defAults
Now press Option+S and the command is corrected to display:
 % defaults
[Editor's note: On my machine, it's the Escape-S key combination that fixes the typo, and it will only fix one wrong character per entry. So "emevs" won't be fixed, but Escape-S on "emecs" will turn it into "emacs".]
    •    
  • Currently 3.33 / 5
  You rated: 4 / 5 (3 votes cast)
 
[3,912 views]  

Fixing command-line typos before hitting enter | 3 comments | Create New Account
Click here to return to the 'Fixing command-line typos before hitting enter' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
option vs meta
Authored by: pmccann on Oct 14, '02 11:42:49AM

The submitter at some stage has ticked the "option key as meta" box in the menu:

Terminal/Window Settings/Emulation

This is very handy if you're an emacs person (I'm not) or spend a lot of term in a shell (I do). The former is pretty obvious (lots of Esc-x type commands in emacs). The latter is useful for things like moving back a word on the command line: Esc-b (or option+b with the box ticked). Moving forward a word at a time is achieved with option-f.



[ Reply to This | # ]
try bindkey
Authored by: awk on Oct 14, '02 01:09:42PM

the hint is just the tip of the iceberg...

Type "bindkey" and you can see all the key bindings in the shell (which you can change, see "man tcsh" for details). Type "bindkey -l" (dash ell) to see short descriptions.

(The "^[" character means you press escape and/or use option, ^X means control-X, etc.)

Here are some I use a lot:

Control-T will transpose the two letters under the cursor. Handy for those "tpyos"..

Esc-Delete will delete the word before the cursor (and then Control-Y can be used to paste it again someplace else). In fact there are lots of cut and paste (kill and yank) commands.

Control-X asterisk (^X*) will expand the sell wildcard you just typed. For instance if you type "rm *" and then "^X*" the star will be expanded to the list of files. Handy if you want to do something to most of the files in a directory but not all. Just expand and then eliminate the ones you don't want.

Esc-L/Esc-U will lowercase/upcase from the cursor to the end of the word.

My favorite is "history search" (Esc-n/Esc-p by default). This lets you type, for example, "defaults " and then hit the keys and it will scroll through all commands in your history that start with "defaults". This is so useful I rebound it to up/down arrow.

You can also set the keys to arbitrary strings, for instance (type it like you see it, carets and all):

bindkey -s "^X^B" "man tcsh^M"

Now ^X^B will give you the tcsh manual,,, you could even bind keys to applescripts using osascript .. skip to the next itunes track from the shell ....

All kinds of stuff in there...........



[ Reply to This | # ]
try bindkey
Authored by: VEGx on Oct 14, '02 04:01:11PM

Cool! I new I was on something when I submitted it :)



[ Reply to This | # ]