Results 1 to 5 of 5
  1. #1


    Member Since
    Apr 03, 2011
    Posts
    10
    keyboard shortcuts for command line navigation in the terminal
    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

  2. #2


    Member Since
    Apr 03, 2011
    Posts
    10
    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?

  3. #3

    TattooedMac's Avatar
    Member Since
    May 19, 2009
    Location
    Waiting for a mate . . .
    Posts
    8,437
    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
    Dont forget to use the Reputation System if someone has helped you out !!!
    Arguing with a zealot is only slightly easier than tunneling through a mountain with your forehead!!!!!
    MoTM ☆☆☆

  4. #4


    Member Since
    Apr 03, 2011
    Posts
    10
    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

  5. #5


    Member Since
    Apr 03, 2011
    Posts
    10
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Terminal command to make aliases (shortcuts) of files/folders?
    By ericconn in forum OS X - Operating System
    Replies: 4
    Last Post: 05-24-2012, 02:16 PM
  2. Terminal: command line to match same base but different extensions?
    By ral152 in forum OS X - Operating System
    Replies: 0
    Last Post: 01-01-2012, 07:21 PM
  3. open new terminal from command line
    By drjimmy42 in forum OS X - Operating System
    Replies: 0
    Last Post: 03-02-2009, 11:06 PM
  4. Keyboard Shortcuts with Duplicate Command Names
    By makker in forum Switcher Hangout
    Replies: 0
    Last Post: 08-08-2008, 11:47 PM
  5. I need help with this command line using Terminal app
    By SniperCrim in forum OS X - Development and Darwin
    Replies: 1
    Last Post: 09-07-2007, 11:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •