Autostart history in gnuplot

In gnuplot, I type

gnuplot> set style data lines 

Then I run a few other lines:

 gnuplot> plot "./data/traj1.dat" u 1:4, "" u 1:6, "" u 1:9, "" u 1:11, "" u 1:13, "" u 1:15 gnuplot> plot "./data/traj2.dat" u 1:4, "" u 1:6, "" u 1:9, "" u 1:11, "" u 1:13, "" u 1:15 gnuplot> plot "./data/traj3.dat" u 1:4, "" u 1:6, "" u 1:9, "" u 1:11, "" u 1:13, "" u 1:15 

Now I want to change the style. I start with

 gnuplot> set 

I want to press, for example, ctrl-r ( http://www.bigsmoke.us/readline/shortcuts ) and run the command before

 gnuplot> set style data lines 

then I can change the lines to points , for example.

How do I do this autocomplete?

+4
source share
2 answers

The partial solution really is to compile gnuplot with readline support. You note that this is your last option in the comments, but I think this is your only option if you do not want to code the gnuplot interface yourself. Maybe this helps to find out that it is very easy to compile gnuplot from ubuntu sources. I just did it myself in & 10 min. Just run (in the directory of your choice) commands

 sudo apt-get purge gnuplot sudo apt-get build-dep gnuplot cd `mktemp -d` apt-get source gnuplot cd gnuplot* ./configure --with-readline=gnu make sudo make install 

Pressing the tab key after writing the first few letters will end the current word, and if you double-click the tab, it will print a list of sentences, as you know, from your gnu shell. Unfortunately, not all readline functions seem to work with the current gnuplot (I know what they did once). For instance. Ctrl + r for reverse lookup (it would be very useful for gnuplot) does not work for me. Hope this helps, although admittedly this is only a partial solution for you.

+4
source

You can use rlwrap to get this function (search history using CTRL + R , file name and keyword) without compiling anything. If you are using Ubuntu, install it from the universe repositories by running:

 sudo apt-get install rlwrap 

Launch gnuplot with:

 rlwrap -a -N -c -b \' -D 2 -s 1000 gnuplot 

where -a -N overrides the built-in readline gnuplot support, -c gives you the completion of the file name, -b \' allows you to fill in things like plot 'incomp[TAB]lete' , -D 2 discards duplicates from the history and -s 1000 increases the size of the story from 300 by default.

Or add this line to your script run (i.e. .bashrc , .zshrc ), so you can use gnuplot without an extra entry:

 alias gnuplot="rlwrap -a -N -c -b \' -D 2 -s 1000 gnuplot" 

In addition, it is possible to complete a keyword by listing all the keywords in the $RLWRAP_HOME/gnuplot_completions . However, context-specific termination is not possible with rlwrap.

You can export the history of gnuplot commands to rlwrap (so you don't have to start from scratch), for example:

 tail -n +2 ~/.gnuplot_history | while read -r; do print $REPLY; done > $RLWRAP_HOME/gnuplot_history 

tail gets rid of the gnuplot header, and print converts escaped characters (I wonder why the history of gnuplot is stored like this).

+1
source

Source: https://habr.com/ru/post/1480186/


All Articles