Installed virtualenv
on my work computer (to which I don't have admin rights) so that I could experiment with Python in my down time during my shift. I typically create different environments for different modules, like scrapy
, twisted
, flask
, etc.
However, once in the environment, and I start traversing directories, I notice that I'm quickly running out of space in Windows' cmd terminal...
(scrapes) C:\Users\Me\Documents\code\scrapes\spiderman\spiderman\spiders\>
Since I can see that my virtual environment is started from \scrapes by the far left prompt, and since I generally don't care about anything outside my environment once I'm in it, I was wondering if anyone had a way of changing the prompt to something a little more palpable; say:
(scrapes) ~\spiderman\spiderman\spiders\>
In other words, I'm to summarize up to the virtualenv folder, replacing it in this case with a ~.
It appears that the prompt is altered using the environments's activate
script (scrapes\Scripts\activate):
activate.bat:
@echo off
set "VIRTUAL_ENV=C:\Users\Me\Documents\code\scrapes"
if defined _OLD_VIRTUAL_PROMPT (
set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
) else (
if not defined PROMPT (
set "PROMPT=$P$G"
)
set "_OLD_VIRTUAL_PROMPT=%PROMPT%"
)
set "PROMPT=(scrapes) %PROMPT%"
if not defined _OLD_VIRTUAL_PYTHONHOME (
set "_OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%"
)
set PYTHONHOME=
if defined _OLD_VIRTUAL_PATH (
set "PATH=%_OLD_VIRTUAL_PATH%"
) else (
set "_OLD_VIRTUAL_PATH=%PATH%"
)
set "PATH=%VIRTUAL_ENV%\Scripts;%PATH%"
:END
It seems like to me that this would only affect the prompt for this environment. If anyone could find a way to summarize paths as a default action of virtualenv, that would be seriously cool