Skip to main content

If I try to create a venv in my home dir, switch to a temp dir instead

ID
c9e6b35
date
2024-10-02 06:31:30+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
55c3e97
message
If I try to create a venv in my home dir, switch to a temp dir instead
changed files
1 file, 2 additions, 2 deletions

Changed files

fish_functions/venv.fish (946) → fish_functions/venv.fish (982)

diff --git a/fish_functions/venv.fish b/fish_functions/venv.fish
index d99dcca..6cded94 100644
--- a/fish_functions/venv.fish
+++ b/fish_functions/venv.fish
@@ -10,8 +10,8 @@ function venv --description "Create and activate a new virtual environment"
 
     # I don't want venvs in my home directory; block it if I try
     if test "$PWD" = "$HOME"
-        echo "You can't create a venv in your home directory!" >&2
-        return 1
+    echo "You can't create a venv in your home directory; switching to temporary directory" >&2
+        cd $(mktemp -d)
     end
 
     echo "Creating virtual environment in "(pwd)"/.venv"