I find myself more than often willing to use the (pdf)latex shell, and \typeout commands there directly - unfortunately, there is one deal breaker: there is no command line history. I think that in Unix terminal emulators (or shells like bash? cannot really tell), this functionality is provided by GNU readline. So, on a readline enabled shell, I can press up and down arrow, and recall past commands, and easily re-execute them with ENTER; and I can also skip words with CTRL + left or right arrow key.

Unfortunately, when I try those combos in my pdflatex shell, I get this:

$ pdflatex 
This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011)
 restricted \write18 enabled.
entering extended mode
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, dumylang, nohyphenation, lo


... that is, I get escaped key sequences like ^[[A, and obviously, there is no keyboard shell navigation.

So my question is: can latex in principle be built with readline support for keyboard shell interaction? I'd understand if distributions would not build it with such support, even if it exists (to reduce dependencies) -- I'm just interested if, in principle, there is an already existing "configure setting" to build latex with readline (at least on *nix systems).

  • 7
    Did you try rlwrap pdflatex? Commented Jul 4, 2014 at 5:04
  • 1
    Oh wow - thanks @phg , that seems to work perfectly! It offers all I wanted - and it will even jump to opening brace, once you've typed a closing brace, to indicate which nesting level you're closing, awesome :) ... Cheers!
    – sdaau
    Commented Jul 4, 2014 at 10:24
  • Dont forget to customize your ~/.inputrc! Commented Jul 4, 2014 at 17:20
  • 1
    @phg, if only I learned this command years ago, to use rogue command line programs like Mathematica... It should be an answer.
    – alfC
    Commented Jan 22, 2015 at 1:33
  • @phg do you mind turning your comment into an answer, to remove this item from the unanswered queue (and to add it to my favourites :o) ?
    – jarnosc
    Commented Oct 31, 2015 at 22:17

1 Answer 1


Per @phg's suggestion, I'll post this answer on his behalf: if running a posix compliant system, try rlwrap tex; that indeed keeps record of keys typed on TeX's command line without linking it to readline.

Your (pdf)latex is very likely simply a symlink to the pdftex interpreter, which is actually what runs under the hood. Having that in mind, from @phg's contribution:

Linking readline would violate the core principles of Luatex and Pdftex. (I don’t know about Xetex -- perhaps they don’t like the license.) On the one hand it means introducing a runtime dependency, on the other hand the library remains platform specific, regardless of how widespread and popular it is. Not the best foundation for extending a feature as controversial as the interactive mode!

An interactive interpreter without readline is quite inconvenient, though. Luckily, that usability gap can be closed quite easily by installing the rlwrap(1) utility. It takes an existing, dumb interpreter and transparently adds a readline layer over the input. This does not affect the output except for what readline would do, e. g. displaying the “insert mode” indicator (show-mode-in-prompt) -- so best avoid it in your scripts.

  • You should copy-and-paste the content of gist.github.com/anonymous/608858f78efac2133bf0 in your answer. It is much more detailed and interesting, I think. I did, but you overwrote my edition.
    – Clément
    Commented Nov 25, 2015 at 21:38
  • @Clément I know. I didn't figure out how to turn it into a comment, which was pretty to the point, actually. My apologies: I'll proceed as you suggest.
    – jarnosc
    Commented Nov 25, 2015 at 21:40
  • @phg fantastic utility. At last I can use etex in interactive mode and do computations with my favorite math engine using \message and access previous inputs simply with arrow keys...
    – user4686
    Commented Nov 25, 2015 at 22:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .