-
-
Save zemlanin/5322437 to your computer and use it in GitHub Desktop.
python quick calculation in zsh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add this file to your ~/.zshrc file and restart zsh | |
# or just run "curl https://gist.github.com/zemlanin/5322437/raw/p.sh >> ~/.zshrc; exec zsh" | |
# | |
# input: | |
# p 2+4 4.0/3 _0+_1 | |
# | |
# and get output like: | |
# _0> 6 | |
# _1> 1.3333333333333333 | |
# _2> 7.333333333333333 | |
__p(){ | |
local args | |
local i | |
local index=0 | |
for i in "$@"; do | |
args+="_$index=eval('$i'); print('\t_$index>', _$index);" | |
let "index+=1" | |
done | |
command python3 -c "$args" | |
} | |
alias p="noglob __p" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment