# showing unstaged, etc., changes at the bash prompt

1 messages from 2009-02-06 to 2009-02-06. Participants: Sitaram Chamarty.
Thread: https://gitlist.dev/t/17606

## Sitaram Chamarty, 2009-02-06 11:20

Subject: showing unstaged, etc., changes at the bash prompt
Message-ID: <slrngoo771.6pi.sitaramc@sitaramc.homelinux.net>
URL: https://gitlist.dev/e/slrngoo771.6pi.sitaramc%40sitaramc.homelinux.net

```
In a thread on "[PATCH v2] bash: offer to show (un)staged changes",
on 2009-02-01, Thomas Rast <trast@student.ethz.ch> wrote:

> Add a bit of code to __git_ps1 that lets it append '*' to the branch
> name if there are any unstaged changes, and '+' if there are any
> staged changes.
>
> Since this is a rather expensive operation and will force a lot of
> data into the cache whenever you first enter a repository, you have to
> enable it manually by setting bash.showDirtyState to a true value.

I'd been doing something a little crazy-sounding that I
thought I should share (for what it is worth).  My problem
was that this expense Thomas mentioned was not just on first
entering a repo, but on *each* command, for some of my users
(long story...  old hardware, wrong kind of "corporate
mandated" software, Windows...  please don't ask <sigh>)

Also, instead of just a symbol, I wanted a *count* of how
many files are staged (git added), modified, untracked,
unmerged, etc.  A color-coded number for each type would be
great.

But I couldn't run this extra stuff at every prompt.  I
wanted it to kick in only when

    * I change directories, or
    * I switch branches, or the branch state (according to
      __git_ps1) changes, or
    * when I want it to, but I won't type a command (huh?)

The idea is that it should be as convenient and accessible
as the current __git_ps1, but it shouldn't really happen on
every prompt.

That last part is a bit of a hack, but basically, if you hit
enter twice in a row quickly at the bash prompt, you get the
more detailed stuff added to __git_ps1's output :-)

Sounds crazy but if you try it, you might just like it...
The link to the shell script is toward the end of
http://sitaramc.github.com/2-command-line-usage/souped-up-bash-prompt.html

Comments welcome but please be kind.  I'm still learning
git, compared to most of you lot :-)

Sitaram

PS: A lot of the color stuff is from
git://github.com/lvv/git-prompt.git

```
