Re: [StGIT PATCH] Bash snippet to show branch and patch in bash prompt

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

 



måndag 30 oktober 2006 10:57 skrev Eran Tromer:
> That's an annoying 430ms delay at every prompt, on my box. Does StGIT do
> something expensive on every invocation?

I don't type fast enough to notice really and my machine seems faster, ~300 ms 
per prompt.

>
> Ben Clifford'd solution is pretty much instantaneous, and the following
> extends it to StGIT (in a less clean but much faster way):
>
> ----------------------------------------------
> __prompt_githead() {
>     __PS_GIT="$(git-symbolic-ref HEAD 2>/dev/null)" || exit
>     __PS_GIT="$(basename $__PS_GIT)"
>     echo -n " $__PS_GIT"
>     __PS_GIT=$(cat "${GIT_DIR:-.git}/patches/$__PS_GIT/current" \
>                2>/dev/null) || exit
>     echo -n ":$__PS_GIT"
> }
> PS1='[\u@\h \W$(__prompt_githead)]\$ '
> ----------------------------------------------

This doesn't work if the branch have a / in the name or if you are in a 
subdirectory, not the top level. Probably not hard to fix though.

-- robin
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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]