tc is yet-another-calculator. This time written in tcl, and it's very easy to personalize. It has a few symbols showing the ways you can customize it. With this script (I put it in ~/bin/tc; chmod +x and rehash), you can write arithmetic expressions in a natural way, avoiding the use of the * and () signs that are preinterpreted by the shells. It is also very easy to add symbols that are replaced before the expression is evaluated. I use it also as a euroconverter, showing how easy it is to expand its behaviour. For example:
% tc sin 3 euRead the rest of the article for the script...
sin(3) * 166.386 = 23.480393661
% tc 2 2
2 * 2 = 4
% tc 2 x 2
2 * 2 = 4
#!/usr/bin/tclsh[Editor's note: I've tested this, and it works just as described.]
# define your own symbols here
set eu 166.386
set pts (1.0/166.386)
set l $argv
# add your substitutions here
regsub -all x "$l" * l
regsub -all eu "$l" $eu l
regsub -all pts "$l" $pts l
regsub -all {([\d\.\)]) +([\(\.\d])} $l {\1 * \2} l
regsub -all {(\w) +([\(\.\d]+)} $l {\1(\2)} l
puts "$l = [eval expr $l]"
Mac OS X Hints
http://hints.macworld.com/article.php?story=20020224124032130