DEV Community

Mike
Mike

Posted on

Just a quickie.

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'
Enter fullscreen mode Exit fullscreen mode

These aliases create a virtualenv in /home/username/.config/venv/directoryname

${PWD##*/}
Enter fullscreen mode Exit fullscreen mode

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)

Collapse
 
andrewbaisden profile image
Andrew Baisden

Great code snippets.

Collapse
 
mikecase profile image
Mike

Thanks!