Terminal.app needs meta; moving around at the command line

Once in a lifetime, you may find yourself needing to edit very long command lines in Terminal.app:

ldapsearch -x -H ldaps://chewbacca.infra.emory.edu:636 -b "dc=Eu,dc=Emory,dc=Edu" -s sub -D hansel -W \
(&(&(&(objectClass=user)(objectCategory=person))(samaccountname=akbarandjeff)(|(memberOf=CN=G LAW STAFF,OU=Global Groups,OU=LAW,DC=Eu,DC=Emory,DC=Edu)(memberOf=CN=G LAW FACULTY,OU=Global Groups,OU=LAW,DC=Eu,DC=Emory,DC=Edu)))) \
cn dn memberOf

If you do, you’ll soon grow tired of having to move the cursor around a character at a time using the arrow keys. Here are the absolute minimum keys that you need to move around effectively at the command line:

  • Ctl-a – moves you to the beginning of the line.
  • Ctl-e – moves you to the end of the line.
  • Meta-b – moves you back one word at a time.
  • Meta-f – moves you forward one word at a time.

Ah… but what is this Meta key? In the Linux world, it’s usually Alt. By default, Terminal.app doesn’t have a key bound to Meta. Fix it by going into the Terminal.app preferences and checking the box labeled “Use option as meta key”.

Use option as meta key.Of course, another alternative would be to ditch these key-bindings (derived from emacs) and switch to a far-superior set of key bindings.

We’ll leave that for another day.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s