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

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.

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 9 comments… read them below or add one }

1 BOK 07.20.05 at 5:15 pm

And another one:
“x7F”: backward-delete-char

PS Nice hints ‘n tips on your site!

2 PotatoSalad 07.17.06 at 7:42 pm

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

3 nixcraft 07.18.06 at 7:05 pm

PotatoSalad,

I am also not sure about freebsd 4.x. If you have the file just copy and use it :)

4 Dan Dascalescu 11.29.06 at 1:24 am

BTW, it’s
“\x7F”: backward-delete-char

Forget the backslash like BOK and your keyboard will be crippled off the ‘x’ key

5 kace 09.20.07 at 8:31 pm

Don’t forget the ‘ctl-v’ trick though. (I mentioned it here.) I’ve found some of those codes are different on different keyboards/machines!

6 Steve Kamerman 09.26.07 at 5:38 pm

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

7 Dagur 03.05.08 at 1:44 pm

It’s also worth noting that if you don’t have permission to edit /etc/inputrc you can at least create a .inputrc file in your home directory

8 BK 05.04.08 at 10:18 am

great!

9 Robvdl 05.25.08 at 2:25 am

Thanks a lot, that fixed the keys in bash, but there’s one more: the END key in the nano editor doesn’t work.

How would I get that going?

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Tagged as: , , , ,

Previous post: FreeBSD > How to enable colorized ls output?

Next post: Linux: Setup as DNS Client / Name Server IP Address