aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclyhtsuriva <aimeric@adjutor.xyz>2025-01-22 20:06:48 +0100
committerclyhtsuriva <aimeric@adjutor.xyz>2025-01-22 20:06:48 +0100
commit15d47a274b617015fb1f1ac9b0203e808ebff31d (patch)
treedd1e723537d60f453207ac8cd59bb24f86446173
parentdfcf6807fed73fd3df4750f1531bd227c324501f (diff)
Enhance bash prompt to display current Git branchHEADmaster
- Added `parse_git_branch` function to extract and format the current Git branch. - Updated PS1 prompt to include the parsed Git branch in a distinct color.
-rw-r--r--dot_bashrc5
1 files changed, 4 insertions, 1 deletions
diff --git a/dot_bashrc b/dot_bashrc
index 50f53a5..553a249 100644
--- a/dot_bashrc
+++ b/dot_bashrc
@@ -31,7 +31,10 @@ export CARGO_HOME="$XDG_DATA_HOME"/cargo
export DOTNET_CLI_HOME="$XDG_DATA_HOME"/dotnet
export GDBHISTFILE="$XDG_CONFIG_HOME"/gdb/.gdb_history
-PS1="\[$(tput bold)\]\[$(tput setaf 1)\][\[$(tput setaf 3)\]\u\[$(tput setaf 2)\]@\[$(tput setaf 4)\]\h \[$(tput setaf 5)\]\w\[$(tput setaf 1)\]]\[$(tput setaf 7)\]\n\\$ \[$(tput sgr0)\]" ; export PS1
+parse_git_branch() {
+ git branch 2>/dev/null | grep '\*' | sed 's/* /(/' | sed 's/$/)/'
+}
+PS1="\[$(tput bold)\]\[$(tput setaf 1)\][\[$(tput setaf 3)\]\u\[$(tput setaf 2)\]@\[$(tput setaf 4)\]\h \[$(tput setaf 5)\]\w\[$(tput setaf 6)\] \$(parse_git_branch)\[$(tput setaf 1)\]]\[$(tput setaf 7)\]\n\\$ \[$(tput sgr0)\]" ; export PS1
[ -f "$HOME/.config/aliasrc" ] && source "$HOME/.config/aliasrc"