Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Why does fn-- (or others) do a home/end in Terminal but a - works everywhere else?

So just to be clear the question is how to make Terminal take Command + and for home and end?

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

As convenient as it would be, Terminal can't easily provide the functionality you ask for.

The reason is that other programs run inside Terminal, like bash (the standard shell) or vi (an editor), which have their own rules for moving the cursor to the beginning/end of the line, for example:

  • bash (and other shells) use CtrlA and CtrlE
  • vi uses 0 and $/Shift4

Other programs may use other keys. There isn't any universal key combination for positioning the cursor at the beginning/end of the line.

Of course, Terminal could maintain a list of key combinations for a number of common programs, check what's running and send the correct keys for you, or it could provide a menu item like Move Cursor To Beginning Of Line Inside Shell ⌘← and then send CtrlA behind the scenes. But I guess Apple engineers thought that if you venture in CLI territory you know its idiosyncrasies.

(Surprinsingly, Terminal provides Option and Option which behaves as you would expect, moving the cursor to the beginning of the previous/next word. That only works reliably in bash, in vi, for example, only the latter works.)

The closest you can get to the standard key combinations and is shift and shift. Go to Preferences...>Settings>[your active profile]>Keyboard:

enter image description here

press +, select "cursor left", "shift" as modifier and action "send string to shell". Then press CtrlA (\001 will appear in the text field`) and OK:

enter image description here

Now add a key combination for "cursor right" and press CtrlE. From now on you can use shift and shift as a poor man's and (notice that it will only work for programs that honor CtrlA/CtrlE).

I'd recommend, though, that you learn the specific key combinations of each program you use in Terminal.

share|improve this answer
1  
Thanks for the detailed answer, is there a petition to just have Apple include a home/end button on the next redesign :-) –  Jackie Nov 12 '12 at 15:09
    
I'm glad I could help. –  jaume Nov 12 '12 at 15:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.