From 86f45a2cd7bc2ba50677e9cdfec3aedcb7b37000 Mon Sep 17 00:00:00 2001 From: Bryan Ramos Date: Fri, 2 Jun 2023 13:11:25 -0400 Subject: [PATCH] Adding git root --- homeConfig/dotfiles/bash/bashrc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/homeConfig/dotfiles/bash/bashrc b/homeConfig/dotfiles/bash/bashrc index edca63a..797c9b6 100644 --- a/homeConfig/dotfiles/bash/bashrc +++ b/homeConfig/dotfiles/bash/bashrc @@ -41,12 +41,15 @@ function set_ps1_prompt() { flake_icon="\[\033[01;34m\]\[\033[00m\]" fi + # Get the root directory of the git repository + git_root="$(basename "$(git rev-parse --show-toplevel)")" + # Get the current directory relative to the Git root cur_dir=$(realpath --relative-to=$(git rev-parse --show-toplevel) .) if [ "$cur_dir" == "." ]; then - cur_dir="\[\033[01;34m\]~\[\033[00m\]" + cur_dir="\[\033[01;34m\] $git_root\[\033[00m\]" else - cur_dir="\[\033[01;34m\]~/$cur_dir\[\033[00m\]" + cur_dir="\[\033[01;34m\] $git_root/$cur_dir\[\033[00m\]" fi else # If not in a Git repository, just show the normal path