When working interactively with gnuplot, the home and end keys do not move the cursor to the beginning and end of a line, but instead produce the characters "OH" and "OF", respectively. What's the reason for this, and how can I get the cursor to move to the beginning and end of a command?
4 Answers
There is a licensing issue between GNU and Ubuntu/Debian regarding the readline library. With this fix, one can compile gnuplot from source and use the following key(s): HOME, END, CTRL+Arrow-Left, CTRL+Arrow-Right
This does not create OH, OF, 1;5D or 1;3D or whatever.
./configure --with-readline=/lib/x86_64-linux-gnu/libreadline.so.6
make
make install
Side remark:
./configure --with-readline=gnu
did not work for me.

- 21
This is a partial answer, regarding to moving to the beginning and end of a line. See help line-editing, for the correct shortcuts in gnuplot. Thus, use CtrlA to move to the beginning and CtrlE end of the line.
`Line-editing`: ^B moves back a single character. ^F moves forward a single character. ^A moves to the beginning of the line. ^E moves to the end of the line. ^H and DEL delete the previous character. ^D deletes the current character. ^K deletes from current position to the end of line. ^L,^R redraws line in case it gets trashed. ^U deletes the entire line. ^W deletes from the current word to the end of line.
I cannot explain why it shows what it shows in your case, however, the linked page says (this is message seems to be version dependent though)
(The readline function in
gnuplot
is not the same as the readline used in GNU Bash and GNU Emacs. If the GNU version is desired, it may be selected instead of thegnuplot
version at compile time.)

- 12,272
-
If you read https://unix.stackexchange.com/a/444270/5132 you should be able to explain why the given characters are shown. – JdeBP Dec 17 '19 at 14:00
This worked for me, but only after installing readline-devel:
./configure --with-readline=gnu
make
make install
You can check with ldd that the proper readline library is linked.

- 41
gnuplot is not a GNU project, though it has been in development by that name since 1986, in retrospect not long after the GNU manifesto (1985). The actual GNU project started sometime in that era (I've seen a variety of dates for that).
Not being a GNU project, there's no reason for it to use a GNU license. Indeed, the copyright notice is permissive but with some restrictions regarding modifications and contact information:
Permission to modify the software is granted, but not the right to
distribute the complete modified source code. Modifications are to be
distributed as patches to the released version. Permission to distribute
binaries produced by compiling modified sources is granted, provided you
1. distribute the corresponding source modifications from the released
version in the form of a patch file along with the binaries,
2. add special version identification to distinguish your version in
addition to the base release version number,
3. provide your name and address as the primary contact for the support
of your modified version, and
4. retain our contact information in regard to use of the base software.
Permission to distribute the released version of the source code along
with corresponding source modifications in the form of a patch file is
granted with same provisions 2 through 4 for binary distributions.
The GPL forbids any restrictions (beyond its own, which include the after-the-fact dynamic linking interpretation), so it is not permitted to distribute an executable for gnuplot using readline (currently GPLv3).
The issue is not specific to Debian and its derivatives such as Ubuntu, but Debian happens to be more careful about licensing than some other organizations. The README.Debian
file for gnuplot notes
Yes, the built in readline of gnuplot is bad. However, libreadline
cannot be used instead because it is licensed under the GPL, whereas
gnuplot has special licenses (patches only). Distribution of those
programs linked together is legally impossible but you may rebuild
your own custom package with readline. Please don't file bugs telling
me to use libreadline in gnuplot...
Debian links gnuplot with libedit, described on James Bigler's page as
libedit is a replacement or alternative to the GNU readline commandline editing functionality. libedit is released under a BSD style licence, so you can use it in your proprietary code.
For simple things such as asked in the question, libedit is capable enough. But it reads from a different configuration file than readline (~/.editrc
rather than .inputrc
). The relevant manual pages would help (you may have the libedit-dev package installed):
The immediate problem for OP was that the home/end keys were not recognized. libedit attempts to get the relevant information from the terminal database (as does readline), but some xterm look-alikes don't match xterm's function-keys, and in any case readline doesn't understand that about half of the terminal descriptions use the application keypad settings (making it wrong half the time).
Rather than improving the libraries, people have taken to propping things up by pasting settings into their .inputrc
file. With libedit, you get to start over again, with the .editrc
file.
Further reading:
- My cursor keys do not work (ncurses FAQ)
- My home/end keys do not work (ncurses FAQ)
- Special Keys (xterm manual)

- 76,765
tmux
"Home" shows1~
for me. – Bernhard Aug 05 '14 at 15:00