bash-git-prompt
bash-git-prompt copied to clipboard
When switching to root, I get a couple of errors: setLastCommandState / setGitPrompt command not found
When I su into root, I get a couple of errors (for each command root issues): bash: setLastCommandState: command not found bash: setGitPrompt: command not found
Using Fedora 21, bash, nothing fancy in .bashrc, nothing custom in root/.bashrc
Great tool otherwise, thanks for sharing it!
In case anybody else has this problem, you need to use su --login to clear your env variables. I have alias su='su --login' in my .bashrc file to make sure. Or you can use export PROMPT_COMMAND="" in root's .bashrc if you need your env variables to be carried over from your normal user.
not very elegant perhaps, but I am getting around this by setting PROMPT_COMMAND to this after sourcing in bash-git-prompt:
command -v setLastCommandState >/dev/null && setLastCommandState; command -v setGitPrompt >/dev/null && setGitPrompt
The source could maybe be updated to do this - it will only call the functions if they are defined in its current environment. This fixes the issue for me, which manifests on Mac OS (Mojave) when using pipenv shell. Thanks for the great tool!