keyboard shortcuts for command line navigation in the terminal

Joined
Apr 3, 2011
Messages
10
Reaction score
0
Points
1
Hi all,
I am a relatively new user to the mac OS (migrating from Ubuntu), and I am still learning the numerous useful keyboard shortcuts.

I use the terminal a lot. One thing that is driving me crazy is how to move the cursor around on the command line.
Besides the arrow keys, here is what I've learned:
[ctrl]-a (takes you to the beginning of the line)
[ctrl]-e (takes you to the end of the line)

[alt]- (left arrow) or (right arrow) does *not* work to move back by 1 word, as it does for example in this editor window as I type.

To move back or forward by 1 word, I found I have to type:
[esc]-b or [esc]-f
and I have to retype [esc]-b *each time* I move back by 1 word, rather than just holding down the [esc] key and arrowing along by a word at a time. :(

This seems like such a trivial point, but it can drive a command line user crazy. Is there some simpler way to move around by a word (or more) at a time on the command line? If there is no default way, can a keyboard sequence be set to do this?

Thanks,

steviep
 
OP
S
Joined
Apr 3, 2011
Messages
10
Reaction score
0
Points
1
Further to my post, I forgot to mention that
[ctrl]-w deletes the previous word, which is very useful.
However, I don't know how to forward-delete the next word... its not
[ctrl]-(delete) , [alt]-w , or [ctrl]-[shift]-w
Anybody know?
 
Joined
May 19, 2009
Messages
8,428
Reaction score
295
Points
83
Location
Waiting for a mate . . .
Your Mac's Specs
21" iMac 2.9Ghz 16GB RAM - 10.11.3, iPhone6s & iPad Air 2 - iOS 9.2.1, ATV 4Th Gen tvOS, ATV3
Ctrl + L Clears the Screen, similar to the clear command
Ctrl + U Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + H Same as backspace
Ctrl + R Let’s you search through previously used commands
Ctrl + C Kill whatever you are running
Ctrl + D Exit the current shell
Ctrl + Z Puts whatever you are running into a suspended background process. fg restores it.
Ctrl + K Clear the line after the cursor
Ctrl + T Swap the last two characters before the cursor
Esc + T Swap the last two words before the cursor
Alt + F Move cursor forward one word on the current line
Alt + B Move cursor backward one word on the current line
Tab Auto-complete files and folder names

Just a few for you

HTH
 
OP
S
Joined
Apr 3, 2011
Messages
10
Reaction score
0
Points
1
Thanks for the commands Tat, [ctrl]-r is a great one that I didn't know about, and so is [esc]-t

My problem is that on my MacBook Pro, the two commands:

Alt + F Move cursor forward one word on the current line
Alt + B Move cursor backward one word on the current line
don't work. On my computer Alt+b gives a little integral sign (like a skinny script S), and Alt+f gives a "forte" sign, like in loud music.

To move back or forward by 1 word, I found that for some reason I have to type:
[esc]-b or [esc]-f
and I have to retype [esc]-b *each time* I move back by 1 word, rather than just holding down the [esc] key and arrowing along by a word at a time. It's just too awkward.

Is there some simpler way to move around by a word at a time on the command line? Or if there is no default way, can I set the keyboard sequence such as [alt]+b, [alt]+f to do this?

steviep
 
OP
S
Joined
Apr 3, 2011
Messages
10
Reaction score
0
Points
1
To answer my own questions, some time ago a colleague fixed the problem using the following (this is my recollection):
From a terminal, go to the menu Terminal -> Preferences -> Settings -> Keyboard
and make sure the box titled "Use option as meta key" is checked.
Then [alt]-f and [alt]-b will go forward or backward one word at a time.
As well, [alt]-d and [alt]-(delete) forward or backward deletes one word at a time.

steviep
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top