From e562996f5c7056fa773a6e78cded83db45605ac5 Mon Sep 17 00:00:00 2001
From: Joel Grunbaum <joelgrun@gmail.com>
Date: Tue, 26 Dec 2023 11:02:48 +0000
Subject: [PATCH] Increase bash history length and add git repo info to prompt

---
 bash/bashrc |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/bash/bashrc b/bash/bashrc
index 875fd74..966eaaf 100644
--- a/bash/bashrc
+++ b/bash/bashrc
@@ -1,5 +1,38 @@
+# Set bash history size
+export HISTSIZE=10000
+export HISTCONTROL=erasedups
+shopt -s histappend
+
 # Prompt, no colours to differentiate it from zsh
-PS1="[\u@\h \W]\$ "
+parse_git_repo() {
+    git remote -v 2>/dev/null | sed -z 's/.*\/\(.*\)\.git.*/\1/g;'
+}
+
+parse_git_branch() {
+    git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
+}
+
+parse_git_tag() {
+    git describe --tags 2>/dev/null
+}
+
+git_prompt() {
+    local ret="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
+    if [ -z $ret ]; then
+        return
+    fi
+    local OUT="$(parse_git_branch)"
+    if [ "$OUT" == " (no branch)" ]; then
+        OUT="($(parse_git_tag))"
+    fi
+    if [ -n "$OUT" ]; then
+        OUT=" ($(parse_git_repo):$OUT)"
+    fi
+    echo "$OUT"
+}
+
+# PS1="[\u@\h \W]\$ "
+PS1="[\u@\h\$(git_prompt) \W]\$ "
 PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
 
 # Common completions

--
Gitblit v1.9.3