[IPython-User] IPython as system shell: showing the git branch in the prompt?
Daniel González Gasull
Sun Sep 5 10:26:13 CDT 2010
I'm trying to make the IPython prompt display the current git branch.
This is the code I have in ~/.ipython/ipy_user_conf.py:
o.prompt_in1 = r'\C_Yellow\u@\h\C_Normal \C_Green\Y2\C_Normal
\C_Cyan%s\C_Normal$ ' % subprocess.Popen('git branch 2>/dev/null',
shell=True, stdout=subprocess.PIPE).communicate().replace('\n', '')
But it doesn't work because the current directory, I found, is always
the directory where ipython was executed. I could add the param cwd
to Popen and pass along the "real" current directory, but I don't know
how to get it.
How can I get the "real" current directory, where the user is at the moment?
http://DjanSoft.com :: Agile Application Development with Python
More information about the IPython-User