FreeBSD: Customize Home, Del, Insert keys for BASH shell

Posted on in Categories FreeBSD, Howto, Sys admin, Tips, Troubleshooting last updated December 1, 2004

By default when you use FreeBSD’s BASH shell and if you hit Home, Del, Insert keys all of them just prints ~ (some garbage is printed ). To get rid of this problem, edit /etc/profile file and define key binding.

1) Open your bash global profile file:
# vi /etc/profile

2) Add following line to it:
export INPUTRC=/usr/local/etc/inputrc

3) Close and save the file

4) Open the file /usr/local/etc/inputrc and define / modify key binding:
# vi /usr/local/etc/inputrc

5) Append following config data:

set meta-flag on
set input-meta on
set convert-meta off
set output-meta on

"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word

6) Close and save the file

7) Now logout and login back again to test your new key settings.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

14 comment

  1. You can just copy /usr/compat/linux/etc/inputrc to /etc/inputrc and add “export INPUTRC=/etc/inputrc” to /etc/profile. Not sure if everyone has the /usr/compat/linux/etc/inputrc file, though. I’m on FreeBSD 6.1

  2. WOW! Thanks – I just switched two dedicated servers from Fedora Core 4 to FreeBSD 6.1 and this was driving me crazy!!!

    Here’s some more handy things to put in your /etc/profile


    alias pico="nano -w"
    alias slocate="locate"
    alias cd..="cd .."
    export EDITOR=/usr/local/bin/nano
    export INPUTRC=/etc/inputrc

  3. Hey there,

    This post is kindof old but still relevant.

    In freebsd 9.x I’ve had to add the following to the inputrc file to really make ctrl-arrow work:

    "e[1;5C": forward-word
    "e[1;5D": backward-word
    "ee[C": forward-word
    "ee[D": backward-word
    

    hope that can be useful for ppl stumbling here.

Leave a Comment