Skip to content

Instantly share code, notes, and snippets.

View lessmost's full-sized avatar

lessmost lessmost

  • Alibaba
  • Hangzhou China
View GitHub Profile
@lessmost
lessmost / venv.fish
Last active March 11, 2024 02:57 — forked from tommyip/venv.fish
Automatically activate/deactivate virtualenv in fish shell
# Based on https://gist.github.com/bastibe/c0950e463ffdfdfada7adf149ae77c6f
# Changes:
# * Instead of overriding cd, we detect directory change. This allows the script to work
# for other means of cd, such as z.
# * Update syntax to work with new versions of fish.
# * Handle virtualenvs that are not located in the root of a git directory.
function __auto_source_venv --on-variable PWD --on-event fish_prompt --description "Activate/Deactivate virtualenv on directory change"
status --is-command-substitution; and return