Learning the existence and shortcuts of GNU Readline made me a better user of Bash and GDB.
But the breakthrough was to learn about (and use) rlwrap (Readline wrapper), which adds Readline functionality to a software which doesn’t (originally) use it (e.g., telnet).
With such a tool, it is possible to C-r, C-p, C-a, C-w, C-y, etc, in any command line interface.
The day I found rlwrap to make the oracle SQL cli tool bearable was a good day
This is an excellent submission. It’s clearly written, has some interesting configuration details, and includes some background on the developer.
Great post but huge missed opportunity to title it “Things you thought you GNU about Readline”
Oh, “horrible confusion”. I like to imagine that GNU pronounces their G in part because Knuth pronounces his K, but I’m probably just mythologizing.
GNU Readline is also why CLISP is part of GNU. There was a (quite spirited) debate about how the GPL would work in practice, since the CLISP authors used GNU Readline but didn’t want to release CLISP under the GPL. In the end, RMS was able to convince them and the rest is (command-line) history.
Like the author I struggled with users who were use to emacs mode and so they couldn’t switch to vi mode without losing their muscle memory. But, I discovered that the vi bindings in INSERT mode are largely a subset of those in emacs mode, so I created a readline config with a vi mode which has all of the emacs key bindings as well. This way folks can use emacs and vi keybindings. I also change the cursor to indicate which vi mode you are in.
My favourite little-known readline command is operate-and-get-next:
You can use it to search back in history with C-r and then execute that command with C-o and keep pressing C-o to execute the commands that followed that one in history. Very helpful for executing a whole block of history.
For some reason, this documentation is hard to find! It’s not here, for example:
The article linked above also seems to be unaware of it, as it recommends clobbering it.
I’m a bit saddened when readline replacements don’t implement C-o. For example, the Python REPLs don’t have it.
The first link is 404. Do you mean https://www.gnu.org/software/bash/manual/html_node/Miscellaneous-Commands.html?