我只想在没有参数的情况下用ipython给python别名,以便我可以使用 ipython 的 shell 及其自动完成功能。例如:
#This should start the ipython shell
python
#These should run python as usual
python -c "print(100)" #run print in python
python --version #run python --version
我正在尝试类似的东西
python() {
if [ "$#" -eq 0 ];
then
ipython
else
eval $(printf "%q " "python $@") #python --help: command not found
#eval $(printf 'python %s\n' "$@") #infinite loop calling python function
fi
}
不需要eval
. 此函数使用env来运行“默认”python 命令
function python() {
if [ "$#" -eq 0 ];
then
ipython
else
env python "$@" # will run python wherever it's installed
fi
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句