bash-git-prompt icon indicating copy to clipboard operation
bash-git-prompt copied to clipboard

When switching to root, I get a couple of errors: setLastCommandState / setGitPrompt command not found

Open joelapatatechaude opened this issue 10 years ago • 2 comments

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!

joelapatatechaude avatar Apr 05 '15 11:04 joelapatatechaude

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.

zcid avatar Oct 03 '15 04:10 zcid

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!

fatal-exception avatar Oct 17 '19 22:10 fatal-exception