9
$\begingroup$

I know that it is possible to run Mathematica in Terminal. But I didn't find a way to get completion work in Terminal. I mean completion by bash-completion style work, who auto completes a command with TAB. How to do this?

$\endgroup$
2
  • 1
    $\begingroup$ Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. $\endgroup$
    – bbgodfrey
    Apr 24, 2015 at 12:50
  • $\begingroup$ An autocomplete in the command line would be a huge improvement in Mathematica, especially for ssh connections. $\endgroup$
    – Thrash
    May 15, 2022 at 21:52

1 Answer 1

3
$\begingroup$

I don't quite have full completion, but I do wrap Mathematica in GNU rlwrap. I know that you can teach rlwrap a list of keywords to autocomplete, and even program it to determine what completions to suggest from your context. At the very least, you get history and line editing out of it.

My recipe:

  • I used MacPorts to install rlwrap, and their port seems to work fine.
  • Create a list of Mathematica definitions that you care about and put it in ~/mathdefs.txt.
  • Then I added alias math='rlwrap -r -f ~/mathdefs.txt /Applications/Mathematica.app/Contents/MacOS/MathKernel' to my login script.
    • The -r tells it to remember words that it sees you type during a session, and the -f ~/mathdefs.txt seeds its completion support with the words that you put in that file.

I notice that Wolfram has added their own history/editing support (probably using readline) in 10.1 at least. Quite possibly before then. I'm sure it wasn't there in 8.0, and I don't think it was in 9.0, but I'm not positive.

$\endgroup$
1
  • $\begingroup$ I found a list of definitions here. But how to make it autocomplete? Which key? TAB doesn't seem to work. $\endgroup$
    – eccstartup
    Apr 25, 2015 at 5:10

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.