I want to be able to type a mathematical expression on the command line and have it evaluate. For example, to just type "5*3" in the shell and press return and it will print 15.
I found the "e" command (
http://www.softnet.tuc.gr/~apdim/projects/e/) which evaluates expressions, thus you can type "e 5*3" and it prints 15. Pretty good BUT it's annoying to type in "e " all the time. Yes, I'm being picky, but I think it should be possible.
Here's my idea: every command you enter in the shell gets redirected to a script. The script runs "which" to find out if it was a valid command. If so, the command runs normally. If it's not a valid command, then it gets sent as input to "e" which tries to evaluate it as a mathematical expression. Real mathematical expressions will almost always be invalid commands so they will be evaluated by "e". Non-math typing errors will also get sent to "e", but I can recompile e so that the resulting error message is appropriate.
My one difficulty is: I don't know how to "redirect" the input to "e". That is to say, how to modify the text of commands before the shell runs them. Any ideas how to do this? My shell of preference is bash.