By running an interpreter trough rlwrap I have access to the command history by pressing the up and down arrow keys. However, I would like to be able to search the command history like I do in Bash (with Ctrl-r). Is there an alternative to rlwrap which has this feature? By the way I use rlwrap version 0.43.

Edit: This problem seems to be related to GNU APL. For other command line interpreters the Ctrl-r command works as expected.

  • No, the problem is not APL-related at all: it happens for all interpreters that do their own line editing (like erlang, Node.js, and many more) The solution is to use an extra -a option with rlwrap (see my answer below) – Hans Lub Sep 26 '19 at 21:27
  • @HansLub I see, thanks! – August Karlstrom Sep 27 '19 at 17:57

From the rlwrap manpage:

-a, --always-readline [password_prompt]
          Always  remain in "readline mode", regardless of command's
          terminal settings.  Use this option if you want to use 
          rlwrap with commands that already do some line editing.

If your interpreter (or any command you want to rlwrap) already has a command history mechanism it is clearly one of those commands.

The way to use rlwrap in such a case is (using the GNU APL interpreter apl as an example):

$ rlwrap --always-readline apl

Be aware, however, that this will override any existing (and, for apl, apparently, very APL-specific history and completion mechanism). How to avoid this (spoiler: you can't!) is actually one of the most often asked FAQs about rlwrap

If you omit the --always-readline then rlwrap will remain "transparent", i.e. it will just hand down all your keypresses to the rlwrapped command, and do nothing.

| improve this answer | |

Works for me out of the box on Debian with Ctrl-R:

$ rlwrap --version
rlwrap 0.42
$ rlwrap cat > /dev/null 
(reverse-i-search)`f': foo

/etc/inputrc and ~/.inputrc apply to Readline even with rlwrap, so they might affect what bindings are available. (But then you did imply it works in Bash, so it's probably not about inputrc.)

| improve this answer | |
  • Your example works for me too. The interpreter I'm having problem with, however, is GNU APL. I find this strange since, as far as I understand, rlwrap should intercept all keystrokes. – August Karlstrom Sep 15 '19 at 7:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.