mirror of
https://github.com/ItsDrike/dotfiles.git
synced 2024-11-10 02:39:40 +00:00
Simplify python alias creation
This commit is contained in:
parent
02237fd0b1
commit
5432334da6
|
@ -79,23 +79,19 @@ alias zb='z -b' # restrict matches to parent directories
|
||||||
alias zi='z -I' # cd with interactive fzf selection
|
alias zi='z -I' # cd with interactive fzf selection
|
||||||
alias zbi='z -b -I' # pick parent directory to cd into with fzf
|
alias zbi='z -b -I' # pick parent directory to cd into with fzf
|
||||||
|
|
||||||
# Python
|
## Make aliases for individual cpython/pypy versions
|
||||||
alias ppy='python'
|
py_versions="\n2\n3\n3.6\n3.7\n3.8\n3.9\n3.10"
|
||||||
alias ipy='ipython'
|
echo "$py_versions" | while read version; do
|
||||||
alias bpy='bpython'
|
for python in python pypy; do
|
||||||
command -v ipython > /dev/null && alias py='ipython' || alias py='python'
|
[ "$python" = "python" ] && prefix="py" || prefix="pypy"
|
||||||
for version in 2 3 3.6 3.7 3.8 3.9 3.10; do # Make aliases for py3.6,py3.7,...
|
|
||||||
if ! command -v "python$version" > /dev/null; then
|
if command -v "$python$version" >/dev/null; then
|
||||||
continue
|
alias "pip$version=$python$version -m pip"
|
||||||
fi
|
alias "$prefix$version=$python$version"
|
||||||
if command -v "ipython$version" > /dev/null; then
|
alias "i$prefix$version=$python$version -c 'import IPython;IPython.start_ipython()'"
|
||||||
alias "py$version"="ipython$version"
|
alias "b$prefix$version=$python$version -c 'from bpython.curtsies import main;import sys;sys.exit(main())'"
|
||||||
alias "ipy$version"="ipython$version"
|
fi
|
||||||
alias "ppy$version"="python$version"
|
done
|
||||||
else
|
|
||||||
alias "py$version"="python$version"
|
|
||||||
alias "ppy$version"="python$version"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Fallbacks
|
# Fallbacks
|
||||||
|
|
Loading…
Reference in a new issue