Calculate with zsh

An easy calculator for the z-shell. Insert into ~/.zshenv:

zcalc () { print $(( ans = ${1:-ans} )) }

Some examples:

% zcalc 5/2 # Division with integer
2
% zcalc 5.0/2 # Division with floating point
2.5
% zcalc "5*2"
10
% zcalc 5%2 # Modulo Operations
1

Comments (0)

2013-08-15 15:05:47