Skip to content

Instantly share code, notes, and snippets.

@lmmx
Created February 7, 2026 21:41
Show Gist options
  • Select an option

  • Save lmmx/9b4f9370354faaaec03178d269fdb45e to your computer and use it in GitHub Desktop.

Select an option

Save lmmx/9b4f9370354faaaec03178d269fdb45e to your computer and use it in GitHub Desktop.
Ascend to the dir containing a .venv
vcd() {
local dir="$PWD"
while [[ "$dir" != "/" ]]; do
if [[ -d "$dir/.venv" ]]; then
cd "$dir" || return
return
fi
dir="$(dirname "$dir")"
done
echo "vcd: no .venv directory found in parent tree" >&2
return 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment