command prompt script for current branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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: curgitbranch.sh
Description: Bourne shell script


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux