{"thread":{"id":"17606","subject":"showing unstaged, etc., changes at the bash prompt","startedAt":"2009-02-06T11:20:01Z","lastAt":"2009-02-06T11:20:01Z","messageCount":1,"participants":["Sitaram Chamarty"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"103456","messageId":"slrngoo771.6pi.sitaramc@sitaramc.homelinux.net","threadId":"17606","inReplyTo":null,"subject":"showing unstaged, etc., changes at the bash prompt","fromName":"Sitaram Chamarty","fromEmail":"sitaramc@gmail.com","sentAt":"2009-02-06T11:20:01Z","receivedAt":"2009-02-06T11:20:01Z","isPatch":false,"sender":{"key":"sitaramc@gmail.com","avatar":"https://avatars.githubusercontent.com/u/43316?v=4"},"body":"In a thread on \"[PATCH v2] bash: offer to show (un)staged changes\",\non 2009-02-01, Thomas Rast <trast@student.ethz.ch> wrote:\n\n> Add a bit of code to __git_ps1 that lets it append '*' to the branch\n> name if there are any unstaged changes, and '+' if there are any\n> staged changes.\n>\n> Since this is a rather expensive operation and will force a lot of\n> data into the cache whenever you first enter a repository, you have to\n> enable it manually by setting bash.showDirtyState to a true value.\n\nI'd been doing something a little crazy-sounding that I\nthought I should share (for what it is worth).  My problem\nwas that this expense Thomas mentioned was not just on first\nentering a repo, but on *each* command, for some of my users\n(long story...  old hardware, wrong kind of \"corporate\nmandated\" software, Windows...  please don't ask <sigh>)\n\nAlso, instead of just a symbol, I wanted a *count* of how\nmany files are staged (git added), modified, untracked,\nunmerged, etc.  A color-coded number for each type would be\ngreat.\n\nBut I couldn't run this extra stuff at every prompt.  I\nwanted it to kick in only when\n\n    * I change directories, or\n    * I switch branches, or the branch state (according to\n      __git_ps1) changes, or\n    * when I want it to, but I won't type a command (huh?)\n\nThe idea is that it should be as convenient and accessible\nas the current __git_ps1, but it shouldn't really happen on\nevery prompt.\n\nThat last part is a bit of a hack, but basically, if you hit\nenter twice in a row quickly at the bash prompt, you get the\nmore detailed stuff added to __git_ps1's output :-)\n\nSounds crazy but if you try it, you might just like it...\nThe link to the shell script is toward the end of\nhttp://sitaramc.github.com/2-command-line-usage/souped-up-bash-prompt.html\n\nComments welcome but please be kind.  I'm still learning\ngit, compared to most of you lot :-)\n\nSitaram\n\nPS: A lot of the color stuff is from\ngit://github.com/lvv/git-prompt.git\n"}]}