Re:Integrated command line math
by peter_l_downs on Tuesday July 23, 2013 @05:44PM
(#6093128)
Or, if you're on OS X, you can just use Spotlight. It includes trig functions, factorials, exponents, etc, and it's only a command-space away. The only downside is that it doesn't automatically copy the result into your clipboard.
Re:Integrated command line math
by danielcorin on Tuesday July 23, 2013 @07:21PM
(#6093549)
I'm surprised that pressing enter on the result in Spotlight doesn't copy it to the clipboard. Amusingly, it opens up the Calculator which I never need after getting the answer.
Re:Integrated command line math
by claudius on Tuesday July 23, 2013 @04:19PM
(#6092636)
‘qalc’ is the command-line version of Qalculate![0] and runs both directly from the command line as well as interactively with tab-completion of variables (Planck mass, for example) and arbitrary unit conversion:
Re:Integrated command line math
by ubasu on Tuesday July 23, 2013 @03:41PM
(#6092421)
That is true, but I have found if I am doing calculations that need something like the full math library of python, it's not a one-off calculation, and I am typically on octave anyway.
In any case, since I have emacs open all time, I usually do
Re:Integrated command line math
by mfincham on Tuesday July 23, 2013 @02:41PM
(#6092045)
A probable improvement on this would be to leave bash out, and just put a python hash bang in the script directly.
I'll leave implementing it as an exercise to the reader. Personally I have found using Guake (http://guake.org/) with IPython as the shell a very nice way of solving this problem.
Re:Integrated command line math
by unfamiliar on Tuesday July 23, 2013 @03:26PM
(#6092337)
For anyone who would like this in an Alfred workflow, make a Script Filter with the following python code (and uncheck all the escape character options):
from math import *
print '<?xml version="1.0"?><items>'
print '<item uid="qcresult" valid="yes" autocomplete="">'
print '<title>'+str({query})+'</title>'
print '</item></items>'
An example: http://i.imgur.com/vaN7HfS.png
I love this idea, I have always found math in the command line to be clunky.
In any case, since I have emacs open all time, I usually do
for one-off calculations.Actually, perhaps I should write one!
I'll leave implementing it as an exercise to the reader. Personally I have found using Guake (http://guake.org/) with IPython as the shell a very nice way of solving this problem.
For example, my .bash_profile contains:
function scrub { ps -ef |grep $1 | grep -v grep | awk '{print $2}' | xargs kill }
mostly because I was too lazy to install pkill, but I can just do `scrub tomcat` and it works.
Also, don't alias a script path. Just add the script to the path.
http://linux.die.net/man/1/xclip