aboutsummaryrefslogtreecommitdiff
path: root/.local/share/bin/=
diff options
context:
space:
mode:
Diffstat (limited to '.local/share/bin/=')
-rwxr-xr-x.local/share/bin/=44
1 files changed, 42 insertions, 2 deletions
diff --git a/.local/share/bin/= b/.local/share/bin/=
index 59b9b45..8f3345d 100755
--- a/.local/share/bin/=
+++ b/.local/share/bin/=
@@ -1,2 +1,42 @@
-#!/bin/sh
-python3 -c "from math import *; deg = pi / 180; print($*)"
+#!/bin/python3 --
+from sys import argv as _argv
+from os import environ as _environ, path as _path
+from math import *
+
+_ans_path = _path.join(_environ["XDG_CACHE_HOME"], "calc_ans")
+try:
+ _ans_file = open(_ans_path, "r+")
+except:
+ _ans_file = open(_ans_path, "w+")
+_exit_code = 0
+
+ans = 0
+try:
+ _ans_str = _ans_file.read()
+ if "." in _ans_str:
+ ans = float(_ans_str)
+ else:
+ ans = int(_ans_str)
+except:
+ pass
+
+deg = pi / 180
+
+MIN = min
+MAX = max
+BIT = lambda n: 1 << n
+GENMASK = lambda h, l: (BIT(MAX(h, l) + 1) - 1) ^ (BIT(MIN(h, l)) - 1)
+
+try:
+ ans = eval(" ".join(_argv[1:]))
+ print(ans)
+except:
+ pass
+
+_ans_file.truncate(0)
+_ans_file.seek(0)
+_ans_file.write(str(ans))
+_ans_file.close()
+
+exit(_exit_code)
+