mirror of
https://github.com/itme-brain/nixos.git
synced 2026-03-24 00:29:43 -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\]"
|
flake_icon="\[\033[01;34m\]\[\033[00m\]"
|
||||||
fi
|
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
|
# Get the current directory relative to the Git root
|
||||||
cur_dir=$(realpath --relative-to=$(git rev-parse --show-toplevel) .)
|
cur_dir=$(realpath --relative-to=$(git rev-parse --show-toplevel) .)
|
||||||
if [ "$cur_dir" == "." ]; then
|
if [ "$cur_dir" == "." ]; then
|
||||||
cur_dir="\[\033[01;34m\]~\[\033[00m\]"
|
cur_dir="\[\033[01;34m\] $git_root\[\033[00m\]"
|
||||||
else
|
else
|
||||||
cur_dir="\[\033[01;34m\]~/$cur_dir\[\033[00m\]"
|
cur_dir="\[\033[01;34m\] $git_root/$cur_dir\[\033[00m\]"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# If not in a Git repository, just show the normal path
|
# If not in a Git repository, just show the normal path
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue