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

Option key command editing shortcuts Apps
When in Terminal, the option key provides you with many shortcuts. Here is a list of these shortcuts that I've found.

For all these shortcuts, hold the Option key and press the character given. When speaking of multiple commands, I mean something like:
 % cd ~/Documents; ls -al; mv *.txt ~/Documents/some_dir
where each phrase is its own command on the same line. Many of these shortcuts are for jumping between these and modifying the current command string. None of these hints deal with commands in the history (such as pressing up and down).

[Editor's note: At first, I couldn't make any of the following shortcuts work. After looking at the prefs for a bit, I noticed that I had enabled "Use option key as meta key" in the Emulation tab of the Display preferences. Once I disabled that, these keys worked as described ... on my G4. On my iBook, with the exact same settings in the prefs (on all tabs), I get accented international characters. Both machines have the same US keyboard showing in the menubar and the same character encoding, so I'm stumped as to what's causing the different behaviors - any ideas? In addition, I believe the following are somehow related to the standard "bindkey" commands, but some of them don't seem to correlate with the "bindkey" defintions - anyone with more expertise care to offer an explanation?]

Once you've got a line with multiple commands on it, then Option- and the following keys will generate (probably?) the described behaviors. In my examples, the red letter is where the cursor is at, and the "aaaa; bbbb; cccc; dddd" is used to represent any string of multiple commands.

------- "a" -------
First press goes to next command and capitalizes the letter the cursor was at. Second press goes to the end of the line and capitalizes the letter the cursor was at.

Before first press:
% aaaa; bbbb; cccc; dddd

After first press, before second press:
% aAaa; bbbb; cccc; dddd

After second press:
% aAaa; Bbbb; cccc; dddd cursor at end of line

------- "c" -------
Same as "a" but jumps to next command with each press instead of the end of the line.

------- "d" -------
Deletes every other previous command from where the cursor is at (best explained with examples).

Before first press:
% aaaa; bbbb; cccc; dddd cursor at end of line

After first press, before second press:
% aaaa; bbbb; dddd

After second press:
% bbbb; dddd

Second example:

Before first press:
% aaaa; bbbb; cccc; dddd

After first press, before second press:
% aaaa; cccc; dddd

After second press:
% aaaa; cccc; dddd

------- "e" -------
Strange effects. Appears to jump backwards but is doing something else also. Experiment on your own.

------- "f" -------
Jumps to end of each following command without modifying the command.

Before first press:
% aaaa; bbbb; cccc; dddd

After first press, before second press:
% aaaa; bbbb; cccc; dddd

After second press:
% aaaa; bbbb; cccc; dddd

------- "g" -------
Jumps to beginning of each command without modifying the command.

Before first press:
% aaaa; bbbb; cccc; dddd

After first press, before second press:
% aaaa; bbbb; cccc; dddd

After second press:
% aaaa; bbbb; cccc; dddd

------- "j" -------
Appears to do the same as "d"

------- "l" -------
Appears do to the same as "g"

------- "m" -------
Goes to beginning of command, then the following character is inserted five times. Using the arrow key as the following character will move the cursor five places. Hitting a letter will insert that letter five times.

------- "o" -------
Appears to do the same as "a"

------- "r" -------
Appears to do the same as "g"

------- "s" -------
Capitalizes the character it is on, then duplicates the current command.

Before first press:
% aaaa; bbbb; cccc; dddd

After first press, before second press:
% aaaa; bbbb; cccc; DdddDddd cursor at end of line

After second press:
% aaaa; bbbb; cccc; DdddDdddDdddDddd cursor at end of line

------- "t" -------
Appears to do the same as "g"

------- "v" -------
Appears to do the same as "d"

------- "x" -------
Appears to do the same as "d"

------- "y" -------
Inserts a backslash "" character.

------- ">" -------
This doesn't modify the command but just list the contents of the CWD.

------- "0" - "9" -------
All seem to go back a command on each press like "g" except for "2" which seems to also list the contents of the CWD, "5" which acts like "d," and "7" which jumps to the previous command on the first press and to the beginning of the line on the second.

--------------

I hope this list is useful to someone. Please feel free to correct me or add any new findings.
    •    
  • Currently 1.50 / 5
  You rated: 2 / 5 (4 votes cast)
 
[6,289 views]  

Option key command editing shortcuts | 3 comments | Create New Account
Click here to return to the 'Option key command editing shortcuts' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Not limited to multiple commands
Authored by: jecwobble on Dec 20, '02 11:07:08AM

I don't think this functionality is limited to multiple commands on a single line. I got similar results when using them on a single, long or complex command like "pwd | pbcopy" or "cd /Library/Webserver/Documents/"



[ Reply to This | # ]
option delete?
Authored by: Tiresias on Dec 21, '02 09:56:05PM

great observation but what use does it have? When is it ever necessary to add 5 characters at the begining of a command?

Personally, I\'d love to have something that deletes the last word. Anyone know how one would do that? it would be great if there was a command to delete the last directory in a path ie /Users/tiresias/Pictures/Mickey would delete Mickey. Or if there was one to delete to the last space like option delete does in many cocoa windows. I wouldn't mind if terminal deleted the whole directory path since It\'s a lot easier to go forward in directory navigation than backwards (such as /U[tab]t[tab]P[tab]M[tab]).



[ Reply to This | # ]
word delete
Authored by: SeanAhern on Dec 23, '02 08:05:40PM

You can delete the last word by typing Control-W.



[ Reply to This | # ]