git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bash snippet to show branch and patch in bash prompt
@ 2006-10-30 10:42 Robin Rosenberg
  2006-10-30 10:46 ` Catalin Marinas
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Robin Rosenberg @ 2006-10-30 10:42 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: Eran Tromer, git

From: Robin Rosenberg <robin.rosenberg@dewire.com>

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---

 contrib/stgbashprompt.sh |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/contrib/stgbashprompt.sh b/contrib/stgbashprompt.sh
new file mode 100755
index 0000000..792da53
--- /dev/null
+++ b/contrib/stgbashprompt.sh
@@ -0,0 +1,16 @@
+# 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\$ '
+

^ permalink raw reply related	[flat|nested] 7+ messages in thread
* Re: [StGIT PATCH] Bash snippet to show branch and patch in bash prompt
@ 2006-10-30  9:57 Eran Tromer
  2006-10-30 10:59 ` [PATCH] " Robin Rosenberg
  0 siblings, 1 reply; 7+ messages in thread
From: Eran Tromer @ 2006-10-30  9:57 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: git

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?

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)]\$ '
----------------------------------------------


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

end of thread, other threads:[~2006-11-02 11:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-30 10:42 [PATCH] Bash snippet to show branch and patch in bash prompt Robin Rosenberg
2006-10-30 10:46 ` Catalin Marinas
2006-10-30 10:57 ` Robin Rosenberg
2006-10-30 10:59 ` Robin Rosenberg
  -- strict thread matches above, loose matches on Subject: below --
2006-10-30  9:57 [StGIT PATCH] " Eran Tromer
2006-10-30 10:59 ` [PATCH] " Robin Rosenberg
2006-10-30 15:03   ` Eran Tromer
2006-11-02 11:24     ` Catalin Marinas

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).