mirror of
https://github.com/ItsDrike/dotfiles.git
synced 2025-06-29 04:00:42 +00:00
Automatically define pyenv python aliases
This commit is contained in:
parent
edd68a210f
commit
480baf8da7
2 changed files with 201 additions and 21 deletions
|
@ -79,27 +79,6 @@ alias zb='z -b' # restrict matches to parent directories
|
|||
alias zi='z -I' # cd with interactive fzf selection
|
||||
alias zbi='z -b -I' # pick parent directory to cd into with fzf
|
||||
|
||||
## Make aliases for individual cpython/pypy versions
|
||||
py_versions="\n2\n3\n3.6\n3.7\n3.8\n3.9\n3.10"
|
||||
# shellcheck disable=SC2139
|
||||
echo "$py_versions" | while read -r version; do
|
||||
for python in python pypy; do
|
||||
[ "$python" = "python" ] && prefix="py" || prefix="pypy"
|
||||
|
||||
if command -v "$python$version" >/dev/null; then
|
||||
if [ "$python" = "python" ]; then
|
||||
alias "pip$version=$python$version -m pip"
|
||||
else
|
||||
alias "ppip$version=$python$version -m pip"
|
||||
fi
|
||||
alias "$prefix${version}pip=$python$version -m pip"
|
||||
alias "$prefix$version=$python$version"
|
||||
alias "i$prefix$version=$python$version -c 'import IPython;IPython.start_ipython()'"
|
||||
alias "b$prefix$version=$python$version -c 'from bpython.curtsies import main;import sys;sys.exit(main())'"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
# Fallbacks
|
||||
command -v hd > /dev/null || alias hd='hexdump -C' # Cannonical hex dump; some systems have this symlinked
|
||||
command -v md5sum > /dev/null || alias md5sum='md5' # Fallback from `md5sum` to `md5`
|
||||
|
@ -295,6 +274,12 @@ if [ ! "$(uname -s)" = 'Darwin' ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
# Autogenerate python aliases
|
||||
if [ -f ~/.config/shell/py-alias ]; then
|
||||
# shellcheck source=/home/itsdrike/.config/shell/py-alias
|
||||
. "$HOME/.config/shell/py-alias"
|
||||
fi
|
||||
|
||||
# Functions
|
||||
if [ -f ~/.config/shell/functions ]; then
|
||||
# shellcheck source=/home/itsdrike/.config/shell/functions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue