Bugzilla – Bug 1227210
bash-git-prompt only works for login shells
Last modified: 2024-07-01 15:09:59 UTC
There's a slight bug in the package, caused by the fact that /etc/profile.d/bash-git-prompt.sh is executed via /etc/profile. Now, the bash-git-prompt works properly when you login for example on a non-graphical TTY, or via SSH (even on localhost), as here we get a login shell. BUT when you enter to a desktop environment, and use a terminal application, bash-git-prompt __git_ps1 gets overridden by /etc/bash_completion.d/git-prompt that comes as part of git-core, as that script is executed for non-login shell by /etc/bash.bashrc So, the sequence of issues to the problem is here: User comes to a login screen (e.g. SDDM) LOGIN -> /etc/profile gets executed /etc/profile.d/bash-git-prompt.sh PROFILEREAD=true Open Konsole /etc/bash.bashrc (and ~/.bashrc) get executed /etc/bash_completion.d/git-prompt is executed -> overrides the previously set git prompt. -> bash-git-prompt is only usable for login shells (sudo -i, ssh, TTY), not in graphical desktop envs. NOTE: it does not matter if for Konsole, you set startup command as '/bin/bash --login' , since PROFILEREAD=true already (I assume), so the bash-git-prompt scripts won't get run. IMPROVEMENT: make bash-git-propmt run in the bashrc -sequence, too.
As a workaround, you of course can do this in your ~/.bashrc: if [ -f /etc/profile.d/bash-git-prompt.sh ] then source /etc/profile.d/bash-git-prompt.sh fi But I assume the idea for it would be to work out-of-the-box just by installing the package and starting a shell.