diff --git a/.config/bash/module/git.sh b/.config/bash/module/git.sh index 005a43d..bf55bcd 100644 --- a/.config/bash/module/git.sh +++ b/.config/bash/module/git.sh @@ -87,6 +87,37 @@ _git_current_branch() git branch --show-current 2> /dev/null } +# Show origin's url. +_git_origin_url() +{ + git remote get-url origin +} + +# Get this dotfiles url. +_git_dotfiles_url() +{ + echo 'https://git.voronind.com/voronind/linux.git' +} + +# Check if current git repo is this dotfiles. +_git_is_dotfiles() +{ + # [[ "$(_git_origin_url)" = "$(_git_dotfiles_url)" ]] + local dir="${PWD}" + + while [[ "${dir}" != "" ]]; do + if [[ -d "${dir}/.git" ]]; then + if [[ "${dir}" = "${HOME}" ]]; then + return 0 + else + return 1 + fi + fi + + dir="${dir%/*}" + done +} + # autocomplete. _completion_loader git &> /dev/null __git_complete gps _git_push &> /dev/null diff --git a/.config/bash/module/ps1.sh b/.config/bash/module/ps1.sh index 91142f5..8a645db 100644 --- a/.config/bash/module/ps1.sh +++ b/.config/bash/module/ps1.sh @@ -44,9 +44,11 @@ __prompt_command() # PS1+="\${PWD}" # Add git branch if available. - local git_branch="$(_git_current_branch)" - if [[ "${git_branch}" != "" ]]; then - [[ "${git_branch}" =~ (master|main) ]] || PS1+=" ${color_bblue}@${git_branch}" + if ! _git_is_dotfiles; then + local git_branch="$(_git_current_branch)" + if [[ "${git_branch}" != "" ]]; then + PS1+=" ${color_bblue}@${git_branch}" + fi fi # set error red