Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying virtualenv

When I am in my virtualenv and it's active, the name of the environment appears in parentheses before the normal command line prompt. It looks like: (foo-env)User:~/Development/foo-env/foo$ where foo-env is the name of the environment. I was wondering if there was a way to make it that the command line prompt displayed something like (F)User:~/Development/foo-env/foo$ as opposed to the current display with (foo-env). If this is possible how would I go about doing this?

like image 878
Etan Avatar asked Jul 26 '11 22:07

Etan


1 Answers

So I figured out how to do this. In the activate script the $PS1 is redefined to prepend the name of the env, in this case (foo-env). In order to prepend it with whatever you want you have to go into the activate script that you run to activate the virtualenv ([yourenv]/bin/activate]). There you change the line that that defines the new $PS1 from PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1" to be whatever you want, here PS1="(F)$PS1".

like image 59
Etan Avatar answered Oct 18 '22 07:10

Etan