Created
December 15, 2021 15:09
-
-
Save davidbgk/51f38d1fc4ecc0c8778a9bab2804beb9 to your computer and use it in GitHub Desktop.
Example of Python aliases + reimplementation of `cd` to auto de/activate the current virtualenv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# aliases | |
alias -g ll='ls -al' | |
alias -g subl='open -a "Sublime Text"' | |
alias server='python3 -m http.server 8000 --bind 127.0.0.1' | |
alias rmvenv='deactivate && rm -rf venv/' | |
alias venv='python3 -m venv venv' | |
alias activate='source venv/bin/activate' | |
alias pipupgrade='python3 -m pip install --upgrade pip' | |
alias requirements='python3 -m pip install -r requirements.txt' | |
# python virtualenv auto de/activation | |
function cd() { | |
if [[ -d ./venv ]] ; then | |
deactivate | |
fi | |
builtin cd $1 | |
if [[ -d ./venv ]] ; then | |
. ./venv/bin/activate | |
fi | |
# also add node_modules/.bin to $PATH | |
if [[ -d ./node_modules ]] ; then | |
export PATH="$(npm bin):$PATH" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment