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

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

 



From: Robin Rosenberg <robin.rosenberg@xxxxxxxxxx>

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

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

diff --git a/contrib/stgbashprompt.sh b/contrib/stgbashprompt.sh
new file mode 100755
index 0000000..a79561e
--- /dev/null
+++ b/contrib/stgbashprompt.sh
@@ -0,0 +1,18 @@
+# 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
+    {
+	git_dir=$(git-rev-parse --git-dir 2> /dev/null)
+	ref=$(git-symbolic-ref HEAD 2> /dev/null)
+	br=${ref/refs\/heads\//}
+	top=$(cat $git_dir/patches/$br/current 2>/dev/null)
+	if [[ -n "$br$top" ]];then
+	    echo "[$top@$br]"
+	    return
+	fi
+    }
+    PS1='\u@\h$(stgtag)\w\$ '
+
+fi
-
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]