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]

 



Eran Tromer <git2eran@xxxxxxxxxx> wrote:
> On 2006-10-30 01:37, Robin Rosenberg wrote:
>> +# include this in your bashrc or copy to /etc/bash_completions.d
>> +
>> +if [ "$PS1" ]; then
>> +    # trap 'PS1="\u@\h [$(stg top)] \w]\$ "' DEBUG
>> +    function stgtag
>> +    {
>> +	br=$(stg branch 2>/dev/null)
>> +	top=$(stg top 2>/dev/null)
>> +	if [[ -n "$br$top" ]];then
>> +	    echo "[$top@$br]"
>> +	    return
>> +	fi
>> +    }
>> +    PS1='\u@\h$(stgtag)\w\$ '
>> +
>> +fi
>
> That's an annoying 430ms delay at every prompt, on my box. Does StGIT do
> something expensive on every invocation?

Well, there are some forks. For every "stg" command, "git-symbolic-ref
HEAD" and "git-rev-parse --git-dir" are invoked to get the name of the
main branch and the .git directory. There is also the delay of
invoking python and loading the command modules in main.py (maybe I
should modify this to import the modules on demand, based on what
command was given).

Since the repository format is stable, you could use something like
this (it should be faster):

git_dir=$(git-rev-parse --git-dir 2> /dev/null)
ref=$(git-symbolic-ref HEAD 2> /dev/null)
br=${ref##*/}
top=$(cat $git_dir/patches/$br/current)

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