sync nvim and make py function better
This commit is contained in:
parent
86e8c713ee
commit
0f329689e6
|
@ -1 +1 @@
|
||||||
Subproject commit 2a6fb440abc22a21d20fb3e4166f414ec43f495a
|
Subproject commit 60fb779958bcc8bf09aa3ed334f2149f7fefbfa0
|
21
.zshrc
21
.zshrc
|
@ -60,8 +60,25 @@ function condac() {
|
||||||
}
|
}
|
||||||
# calculate on shell with `c 1+1`
|
# calculate on shell with `c 1+1`
|
||||||
function c() { printf "%s\n" "$@" | bc -l; }
|
function c() { printf "%s\n" "$@" | bc -l; }
|
||||||
# call python in a print from args
|
# Call Python and execute multiple statements from args
|
||||||
function py() { python -c "from math import *; print($*)" }
|
function py() {
|
||||||
|
python <<< "
|
||||||
|
from math import *
|
||||||
|
|
||||||
|
def evaluate_and_print(code):
|
||||||
|
for expr in code.split(';'):
|
||||||
|
expr = expr.strip()
|
||||||
|
if '=' in expr:
|
||||||
|
exec(expr)
|
||||||
|
else:
|
||||||
|
result = eval(expr)
|
||||||
|
print(f\"{expr} => {result}\")
|
||||||
|
|
||||||
|
if __name__ == \"__main__\":
|
||||||
|
expr = '$*'
|
||||||
|
evaluate_and_print(expr)
|
||||||
|
"
|
||||||
|
}
|
||||||
|
|
||||||
### ---- zsh options -------------------------------------
|
### ---- zsh options -------------------------------------
|
||||||
setopt autocd
|
setopt autocd
|
||||||
|
|
Loading…
Reference in New Issue