Created
December 2, 2021 20:24
-
-
Save jmbwell/c1e0f008a3abed7e182e40bc8308f380 to your computer and use it in GitHub Desktop.
zsh autocompletion for activating python virtualenvs
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
# zsh example for python virtualenv activation shortcuts with autocomplete | |
# | |
# - Assumes your virtualenvs are stored in the directory ~/virtualenvs | |
# | |
# To use, type activate, then press tab to get a list of available virtualenvs | |
# Example: act<tab> ans<tab> to do "activate ~/virtualenvs/ansible" | |
# 1. Activate enhanced completion in zsh | |
autoload -Uz compinit && compinit | |
# 2. Create alias shortcut to activate a python virtualenv | |
activate() { source ~/virtualenvs/$1/bin/activate } | |
# 3. Define autocomplete for available virtualenvs | |
compdef '_files -W $HOME/virtualenvs -/ -S "" -F "*/*"' activate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment