SSH & special keys

Hi,

I noticed that the default RedHat distributions work really well with keyboards – for example, the 'Home' and 'End' keys function as exepcted while I'm typing at a shell prompt.

It's a little different under Debian, and I'd imagine I have to install something to get the same functionality. Does anyone know what I have to install/change to set that up in a Debian environment? Currently the 'Home' and 'End' keys result in a "~" character with a beep that occurs at the same time. Interestingly, however, in nano-editor, the Home and End keys work just fine.

Thanks for your help!

j.

4 Replies

Put this in /etc/bash.bashrc to enable for all logins:

case $TERM in
        xterm*)
                if [ "$COLORTERM" ]; then
                        bind '"\C-h": backward-delete-char'
                        bind '"\e[3~": delete-char'
                        bind '"\e[7~": beginning-of-line'
                        bind '"\e[8~": end-of-line'
                else
                        bind '"\e[1~": beginning-of-line'
                        bind '"\e[3~": delete-char'
                        bind '"\e[4~": end-of-line'
                        bind '"\177": backward-delete-char'
                fi
                ;;
        cons*)
                export COLORTERM=$TERM
                bind '"\C-?": delete-char' # DEL
                bind '"\C-h": backward-delete-char' # BACKSPACE
                bind '"\e[H": beginning-of-line' # HOME
                bind '"\e[F": end-of-line' # END

esac

You'll have to re-login for it to take effect.

Thanks for the quick reply! – I copied the code and pasted it directly into /etc/bash.bashrc, then exited and reconnected through SSH but it hasn't seemed to have changed anything. I took a look at 'env' and it reports TERM=xterm and SHELL=/bin/bash.

Any idea why it wouldn't have changed anything? The 'Del' key has always worked, the 'Insert' key doesn't, the 'Home' and 'End' keys still give the beep and the '~' character.

Should I try pasting that code into ~/.bashrc? Or would that do bad things?

Thanks again for your help!

j.

might try ~/.bashrc maybe the global isn't getting ran for some odd reason.

Yep – that worked. Thanks! :)

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct