From 8faef2071a0dd0358714b082738dbc253378214a Mon Sep 17 00:00:00 2001 From: Harald Pfeiffer Date: Sun, 14 Jul 2024 09:59:33 +0200 Subject: inclusion of git prompt --- .bash/postexec.bash | 7 +++++++ .bash/prompt.bash | 14 +++++++++++++- .gitignore | 1 + .gitmodules | 3 +++ git-prompt | 1 + 5 files changed, 25 insertions(+), 1 deletion(-) create mode 160000 git-prompt diff --git a/.bash/postexec.bash b/.bash/postexec.bash index 564356a..6137814 100644 --- a/.bash/postexec.bash +++ b/.bash/postexec.bash @@ -6,3 +6,10 @@ if [ -n "$SSHENVFILE" ] && [ -r "$SSHENVFILE" ];then fi fi fi +for gitpsrc in "/usr/share/git/git-prompt.sh" "/usr/local/share/git/git-prompt.sh" \ + "/usr/share/git-completion/prompt.sh" "/usr/local/share/git-completion/prompt.sh"; do + if [ -r "$gitpsrc" ]; then + source "$gitpsrc" + break + fi +done diff --git a/.bash/prompt.bash b/.bash/prompt.bash index 6914d63..225b776 100644 --- a/.bash/prompt.bash +++ b/.bash/prompt.bash @@ -145,7 +145,19 @@ __prompt_command() { PS1="\\# \[$(tput bold)\]\[$($FGC1)\]\t \[$($FGC2)\]\\u$UHSEP\[$($FGC3)\]$PHN \\w \[$(tput sgr0)\]\\n" ;; esac - if command -v __git_ps1 >/dev/null 2>&1;then PS1+="$(__git_ps1 "%s ")";fi + # git-completion. Sources: + # - https://github.com/git/git/tree/master/contrib/completion (main) + # - https://github.com/felipec/git-completion (fork) + # - Debian: easygit + # - Arch: git-completion (AUR, with functionality tests) - search for ...share/git(-completion)?/prompt.sh + # - Manual measure: this repository, /git-prompt + # Why all this fuss? magicmonty takes control over the whole prompt, __git_ps1 only serves a part + # of it. We don't like monoliths, we like modules; the latter is good practice. + # also, see postexec --> one-time sourcing of git's prompt.sh + if command -v __git_ps1 >/dev/null 2>&1;then + GIT_PS1_SHOWCOLORHINTS=1 + PS1+="$(__git_ps1 "%s ")" + fi if [ "$EXIT" -eq 0 ];then PS1+="\[\033[0;32m\]# " elif [ "$EXIT" -eq 255 ]||[ "$EXIT" -eq 127 ];then diff --git a/.gitignore b/.gitignore index d049053..fccf319 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ !/.vimrc !/.ssh/config !/.ssh/config.d/0000-all.conf +!/git-prompt diff --git a/.gitmodules b/.gitmodules index d2a5366..c15f58a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,3 +6,6 @@ path = tmux-yank url = https://github.com/tmux-plugins/tmux-yank branch = master +[submodule "git-prompt"] + path = git-prompt + url = ./git-prompt diff --git a/git-prompt b/git-prompt new file mode 160000 index 0000000..c2b3f2b --- /dev/null +++ b/git-prompt @@ -0,0 +1 @@ +Subproject commit c2b3f2b3cdbf5ad9feb978dd367d77561a1271f7 -- cgit v1.2.3