mirror of
https://github.com/itme-brain/nixos.git
synced 2026-03-24 08:39:42 -04:00
Adding git root
This commit is contained in:
parent
06031cb78a
commit
86f45a2cd7
1 changed files with 5 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue