Skip to content

Instantly share code, notes, and snippets.

@ronelliott
Last active August 3, 2019 13:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ronelliott/5182246 to your computer and use it in GitHub Desktop.
Save ronelliott/5182246 to your computer and use it in GitHub Desktop.
Helpful Bash Aliases for Pip
alias pir="pip install -r requirements.txt"
alias pip-upgrade-all="pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip install -U"
pip_freeze() {
echo "Freezing to 'requirements.txt'"
pip freeze > requirements.txt
}
pip_install() {
pip install $@
}
pip_uninstall() {
pip uninstall -y $@
}
pip_install_freeze() {
pip_install $@ && pip_freeze
}
pip_uninstall_freeze() {
pip_uninstall $@ && pip_freeze
}
alias pi='pip install'
alias pif=pip_install_freeze
alias pf=pip_freeze
alias pu='pip uninstall -y'
alias puf=pip_uninstall_freeze
@pythoninthegrass
Copy link

Came from your Coderwall. You've avoided a pitfall by breaking the functions into multiple lines for this gist, but the original post is problematic. For the functions you need to add a ; before the closing curly bracket to avoid a syntax error on one-liners. For example, pip_install() { pip install $@; }.

Been a while since I messed around with functions in a bash profile and it took a bit of time to track that down. Thanks for posting the gist -- helpful to simplify routine pip operations ^_^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment