I have forever had problems with the Terminal not acting as it should. For instance, the Home and End keys did not do what I expected them to. Well, I finally found out how to get everything working perfectly. Just open a Terminal and type:
export TERM=linuxIt works for Terminal, it works when I'm ssh'ed into Linux, it works when I'm ssh'ed into FreeBSD, it works in Postgres psql. It just works. Finally a solution.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20041102133243355