Here are the aliases that I use for python virtual environments.
# aliases for venv (python-venv)
alias create-venv='python3 -m venv /home/${USER}/.config/venv/${PWD##*/}'
alias remove-venv='rm -rf /home/${USER}/.config/venv/${PWD##*/}'
alias activate-venv='source /home/${USER}/.config/venv/${PWD##*/}/bin/activate'
These aliases create a virtualenv in /home/username/.config/venv/directoryname
${PWD##*/}
Gets only the directory name your currently in, not the full path.
I.E. the full path '/home/username/code/python/app_name' ${PWD##*/} returns only app_name
Top comments (2)
Great code snippets.
Thanks!