How to make HOME or END keys work in mc running on OS X (ssh)

9

6

I installed MacPorts on OS X 10.5 and I found out that when I connect to the computer using SSH and use mc - Midnight Commander - the HOME and END keys do not work.

I have to mention that I'm using putty and I am able to use the keyboard very well on Linux machines like Fedora, Ubuntu,...

Here is putty keyboard configuration (a configuration I found to be optimal over time):

  • Backspace key: 127
  • Home/End keys: Standard
  • Function keys: Xterm R6
  • Cursor keys: Normal
  • Numpad: normal
  • Terminal type string: xterm-color

I'm looking for a command line solution/script that does these changes, this make much easier to create a prepare OS script for configuring a new OS.

sorin

Posted 2009-07-22T11:13:09.147

Reputation: 9 439

Answers

11

The keyboard mappings for home and end in Terminal.app are not direct, but you can fix them. To get them to work directly, go to Terminal -> Preferences... -> Settings screen -> Keyboard and then find the lines for these keys and click the edit button for them (or add them if they are missing for some reason).

Be careful to not have any leading or trailing spaces as well for these.

home key code:

\033[H

end key code:

\033[F

page-up key code:

\033[5~

page-down key code:

\033[6~

Screenshot1

Screenshot2

Lara Dougan

Posted 2009-07-22T11:13:09.147

Reputation: 2 266

1\033 is entered by pressing the escape key – jlsecrest – 2014-06-26T07:52:07.557

I wasn't able to enter the sequences because backslash is auto-translated to double-backslash (OS X 10.6). Also, I would prefer a script/command line for doing these settings (if possible). – sorin – 2010-03-09T06:52:40.750

@Sorin Strange, I am running OS 10.6 and that's the OS I did my screenshots with, but then again I made my profile on 10.5. It appears that typing in the control sequence into TextEdit and then doing a copy and paste into the field works fine. – Lara Dougan – 2010-03-11T07:10:07.453

Legend, thanks! PageUp and PageDown now work properly in vim :-) – Sonia Hamilton – 2013-12-17T04:17:11.670

5

The actual question was how to use Home and End keys with PuTTY when logged into OSX using ssh.

First, I changed the settings in the OSX Terminal.app preferences according to this link. It worked for me to fix Home and End keys for usage on desktop. However when logged into OSX remotely with PuTTY, Home and End keys still didn't work. So I modified PuTTY terminal as below:

Go to PuTTY configuration > Terminal > Keyboard
find "The function keys and keypad"
instead of
ESC[n~
choose
SCO
click Apply.

Your Home and End keys should work properly now on your PuTTY terminal when you are logged into OSX.

You can set and save different settings for your different sessions. When you login to other type machines you may use standard PuTTY setting.

baltasvejas

Posted 2009-07-22T11:13:09.147

Reputation: 151

Setting "Function keys and keypad" to "SCO" fixes the home/end keys, but unfortunately breaks the F-keys in Midnight Commander... – Vladimir Panteleev – 2015-09-13T01:02:42.093

This repairs Home and End but changes the Del key to Backspace. – cweigel – 2018-02-06T15:17:35.417

2

Hold down the shift key for Home/End PgUp/Pg down in Terminal.app in order to not let Terminal use these keys for the scrollback. This way (with shift) Terminal will pass the keys on to the application running in the window.

Cairo

Posted 2009-07-22T11:13:09.147

Reputation: 434

-1

I had a similar problem after switching to the Mac. In OS X, Home and End take you to the start and finish of a document respectively. Think of them as Page Up and Page Down on steroids.

To do the equivalent to the Windows usage of Home and End, use Command+Left Arrow and Command+Right Arrow.

Brian Willis

Posted 2009-07-22T11:13:09.147

Reputation: 672

1Sorry but this a different problem and is not related to the one specified to you. – sorin – 2009-07-31T12:11:32.477