24
$\begingroup$

I would like to perfom such feats as cycling through previous commands, editing commands in place, etc. My expectation would be a readline-like interface, but this appears to not be the default.

$\endgroup$
4
  • $\begingroup$ Just curious: Why would you use the command line? Even for remote kernels, working with a frontend would be possible. $\endgroup$ Commented Sep 27, 2012 at 19:48
  • $\begingroup$ @SjoerdC.deVries sometimes configuring remote access can be painful, especially over ssh. $\endgroup$
    – rcollyer
    Commented Sep 27, 2012 at 19:49
  • 1
    $\begingroup$ you could also just use emacs as a frontend for mathematica (there are modes for that) $\endgroup$
    – acl
    Commented Sep 27, 2012 at 22:04
  • $\begingroup$ @acl there are modes for everything in emacs. $\endgroup$
    – rcollyer
    Commented Sep 28, 2012 at 1:30

2 Answers 2

25
$\begingroup$

If you want readline-like behavior you can of course use a readline wrapper. This works on all operating systems. On Ubuntu Linux (and other distributions I'm sure too) it can be installed easily through the package management. On Max OSX this can be installed using for instance MacPorts and I'm sure, there is an easy option on Windows too. Anyway, on all systems you can compile it yourselft. The usage is then

rlwrap math 

on Linux or

rlwrap /Applications/Mathematica.app/Contents/MacOS/MathKernel 

on Mac OSX. Try it and be surprised ;-)

$\endgroup$
6
  • 3
    $\begingroup$ Very cool! I didn't know about rlwrap (and I had the same experience as the OP when I tried the CLI out of curiosity). $\endgroup$
    – rm -rf
    Commented Sep 27, 2012 at 20:40
  • 3
    $\begingroup$ @rm-rf sometimes I wonder whether it's because the most guys at Wolfram are Windows-guy. They really just give a <insert very rude word of your choice here> about the command line. $\endgroup$
    – halirutan
    Commented Sep 27, 2012 at 20:44
  • $\begingroup$ I used to use the kernel interface extensively, and for a while there, I got quite good at it. Of course, the notebook interface didn't exist when I started using mma, but that dates me a little to well, I think. $\endgroup$
    – rcollyer
    Commented Sep 28, 2012 at 1:34
  • $\begingroup$ @halirutan I'd assume that this is because most people use the notebook interface for daily work. Then the command line interface doesn't get much love. $\endgroup$
    – Renan
    Commented Sep 28, 2012 at 1:40
  • $\begingroup$ @halirutan: Thanks, I was able to build this from source and use it. $\endgroup$
    – intermath
    Commented Sep 28, 2012 at 16:33
18
$\begingroup$

If you're on Windows: which command line interface are you talking about?

The "math.exe" program is a console mode (i.e. "DOS prompt") interface to the Mathematica kernel. If you use that, you have access to the standard Windows console command-line editing; it is automatically provided by the OS to all console mode programs. You can use the arrow keys to move around in previous commands, and you can edit, insert, and delete, copy, cut and paste using the traditional DOS-style editing and function keys.

The "MathKernel.exe" program -- which is what appears as "Wolfram Mathematica 8 Kernel" in your Start Menu -- is a very simple GUI windowed interface without any line editing or other special features.

I usually use the Mathematica kernel by running "math.exe" inside a console, which I have set to be as tall as the screen and with a very large scrollback buffer (set using the console's "Properties" menu).

A LATER UPDATE: In Mathematica 9, the "math.exe" program uses a new and different keyboard editing system that it did before, one based on GNU readline. But you can get rid of that and go back to standard Windows console command-line editing by removing or renaming the file term.dll in $TopDirectory\SystemFiles\Kernel\Binaries\Windows (32 bit) or Windows-x86-64 (64 bit).

AN EVEN LATER UPDATE: term.dll is now in $TopDirectory\SystemFiles\Libraries\Windows or ...\Windows-x86-64

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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