git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* command prompt script for current branch
@ 2008-02-06 19:52 Stephen Sinclair
  2008-02-06 20:42 ` Junio C Hamano
  2008-02-06 21:09 ` command prompt script for current branch Jakub Narebski
  0 siblings, 2 replies; 16+ messages in thread
From: Stephen Sinclair @ 2008-02-06 19:52 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 1339 bytes --]

Hello,

Attached is a script I quickly wrote up yesterday.  Sometimes I've
found I started working only to realize I was on the wrong branch.
(Now that I'm accustomed to working with git, I make many small
branches, so it happens.)

So I made this small script to simply write the name of the currently
checked out branch, as well as information on how many commits it
differs from the remote tracking branch, if any.
It also appends an exclamation mark if I have uncommitted changes.  I
stuck it in my PS1 environment variable, so that it would be part of
my command prompt.

I tried to choose git commands that would be relatively quick, since
this will be run for every single command prompt.  If I've chosen
suboptimal ways of doing this, please let me know.  There's a few too
many 'grep' and 'sed' commands for my liking, so maybe there is a way
to get the same information more directly instead of parsing git
command output.  Anyways, if it's of general interest, I'd be happy to
make a patch for /contrib.

For my tiny git repos, this seems to have pretty much no negative
impact on my work flow.  When I cd'd to my git.git clone there was
about a 1/2-second delay the first time, but subsequent command
prompts incurred no visible delay.  I've no idea how fast it would be
for something as big as the kernel, for example.

Steve

[-- Attachment #2: curgitbranch.sh --]
[-- Type: application/x-sh, Size: 1960 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2008-02-08 14:07 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-06 19:52 command prompt script for current branch Stephen Sinclair
2008-02-06 20:42 ` Junio C Hamano
2008-02-06 22:14   ` [PATCH (repost)] Improve bash prompt to detect merge / rebase in progress Robin Rosenberg
2008-02-06 22:23     ` Robin Rosenberg
2008-02-06 22:31     ` Junio C Hamano
2008-02-07  0:23       ` Robin Rosenberg
2008-02-07  6:34         ` Shawn O. Pearce
2008-02-08 11:26           ` Steffen Prohaska
2008-02-08 12:25             ` Johannes Schindelin
2008-02-08 13:12               ` Steffen Prohaska
2008-02-08 14:06                 ` [PATCH/RFC] Make git-completion.bash a first-class citizen Johannes Schindelin
2008-02-06 23:21     ` [PATCH (repost)] Improve bash prompt to detect merge / rebase in progress Jakub Narebski
2008-02-06 23:44       ` Mike Hommey
2008-02-06 21:09 ` command prompt script for current branch Jakub Narebski
2008-02-06 22:13   ` Stephen Sinclair
2008-02-06 22:56     ` Jakub Narebski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).