Skip to content

Instantly share code, notes, and snippets.

@zemlanin
Last active December 15, 2015 20:59
Show Gist options
  • Save zemlanin/5322437 to your computer and use it in GitHub Desktop.
Save zemlanin/5322437 to your computer and use it in GitHub Desktop.
python quick calculation in zsh
# 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