summaryrefslogtreecommitdiff
path: root/tmuxsh/_calc,--.calculator.with.bc.or.python.(ctrl-d.to.exit)
diff options
context:
space:
mode:
Diffstat (limited to 'tmuxsh/_calc,--.calculator.with.bc.or.python.(ctrl-d.to.exit)')
-rwxr-xr-xtmuxsh/_calc,--.calculator.with.bc.or.python.(ctrl-d.to.exit)21
1 files changed, 21 insertions, 0 deletions
diff --git a/tmuxsh/_calc,--.calculator.with.bc.or.python.(ctrl-d.to.exit) b/tmuxsh/_calc,--.calculator.with.bc.or.python.(ctrl-d.to.exit)
new file mode 100755
index 0000000..c0f9ce5
--- /dev/null
+++ b/tmuxsh/_calc,--.calculator.with.bc.or.python.(ctrl-d.to.exit)
@@ -0,0 +1,21 @@
+#!/usr/bin/env sh
+helpmsg() {
+ printf "%s\n" "desc: commandline calculator (ctrl+d to exit)"
+ printf "%s\n" "demo: http://www.youtube.com/watch?v=JkyodHenTuc"
+ printf "%s\n" "depends: python2, python3 or bc"
+ printf "\n"
+ printf "%s\n" "usage: ${0##*/}"
+}
+if [ "$1" = -h ] || [ "$1" = --help ]; then
+ helpmsg
+ exit 0
+elif command -v python3 >/dev/null; then
+ python3 -ic "from math import *; import cmath"
+elif command -v python2 >/dev/null; then
+ python2 -ic "from __future__ import division; from math import *; from random import *"
+elif command -v bc >/dev/null; then
+ bc -q -l
+else
+ printf "%s\n" "missing python2, python3 or bc"
+ exit 1
+fi