Can I display GIT in prompt when current directory has/contains a .git
folder? Is there a way to do this? My current prompt is defined like so:
export PS1="[\u@\h] \w $ "
So, my prompt looks like this:
[user@computer] ~/workspace $
And I want it to dynamically look like this:
[user@computer] ~/workspace GIT $
Best Answer
The most standard way is to use
__git_ps1
directly from git. In Ubuntu, it is available in this path:You can notice the added part
$(__git_ps1 "(%s)")
, which will notify you about the current state of repo -- current branch, ongoing rebases, merges and so on.The file in Ubuntu is provided by
git
package:For fedora by
git-core
(with a bit different path):Your prompt will change from
to