Skip to content

Instantly share code, notes, and snippets.

@bskinn
Created January 19, 2021 16:53
Show Gist options
  • Save bskinn/eb4a30aaac418b63e602ad3dba4c727c to your computer and use it in GitHub Desktop.
Save bskinn/eb4a30aaac418b63e602ad3dba4c727c to your computer and use it in GitHub Desktop.
Windows batch file for quick virtualenv creation
@echo off
for /f "tokens=*" %%C in ( 'python3.9 -c "import os, re; print(re.search(r'[^\\]+$', os.getcwd(), re.M).group(0))"' ) do (
set DIRNAME=%%C
)
if [%2]==[] (
python%1 -m virtualenv env --prompt="(%DIRNAME%) "
) else (
python%1 -m virtualenv env --prompt="(%2) "
)
@bskinn
Copy link
Author

bskinn commented Jan 19, 2021

Variation of this.

cmd IF syntax here.

Would be better to use pathlib, but that's less concise for a one-liner.

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