Enabling command history in terminal programs like Sicstus

When you get used to pressing the up arrow for history items, the tab auto-complete feature and other handy features in the Linux terminal, it can be irritating when the occasional program behaves differently.

I have been using SICStus Prolog for my CS Prolog course and have been irritated by SICStus picking up the up arrow key as ^[[A and not retrieving the last thing I typed.

To get it to work like the Bash shell and other programs do, you can use rlwrap [program].

This program allows you to ‘wrap’ a program you’re running, like SICStus, in the readline attribute. This contains the features you’re used to. Just type something like this at the terminal, e.g.

It will ‘wrap’ your program in the readline function and work as expected. Voila!

If you want more information on rlwrap, check out the man (manual) page.