sync nvim and make py function better

This commit is contained in:
Christoph J. Scherr 2024-07-16 12:30:34 +02:00
parent 86e8c713ee
commit 0f329689e6
2 changed files with 20 additions and 3 deletions

@ -1 +1 @@
Subproject commit 2a6fb440abc22a21d20fb3e4166f414ec43f495a
Subproject commit 60fb779958bcc8bf09aa3ed334f2149f7fefbfa0

21
.zshrc
View File

@ -60,8 +60,25 @@ function condac() {
}
# calculate on shell with `c 1+1`
function c() { printf "%s\n" "$@" | bc -l; }
# call python in a print from args
function py() { python -c "from math import *; print($*)" }
# Call Python and execute multiple statements from args
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 -------------------------------------
setopt autocd