Skip to content

Instantly share code, notes, and snippets.

@gidgid
Created April 10, 2020 17:28
Show Gist options
  • Save gidgid/2a2e5952e4d6c02c4c1c02398d046027 to your computer and use it in GitHub Desktop.
Save gidgid/2a2e5952e4d6c02c4c1c02398d046027 to your computer and use it in GitHub Desktop.
Activating virtual envs with FZF
vf() {
# note that you need to extract the absolute path in order to get this to work
ls -d ~/.virtualenv/*/ | fzf | while read file; do source $file/bin/activate; done
}
@jelinekb
Copy link

Used find and null termination to avoid ls breaking on paths that contain spaces.

source "$(find ~/.virtualenvs/ -maxdepth 1 -type d -print0 | fzf --read0)"/bin/activate

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