I'm using the following code to get a nice prompt (including git information etc.):

function set_prompt {
    # magic happens in here ;)

export PROMPT_COMMAND='set_prompt'

However, sometimes I get the following warning after using certain programs that make heavy use of bash internally:

bash: set_prompt: command not found

One good example for this is Gentoo's package manager emerge which shows that error when it exists. It's not a big deal - just looks ugly and doesn't break anything. But I'd like to get rid of it anyway.

I assume it happens because the PROMPT_COMMAND environment variable is inherited by emerge's shells but the function isn't.

Is there some way to make the PROMPT_COMMAND variable as not inheritable? Or another way to avoid this annoying issue?

1 Answer 1


Don't export PROMPT_COMMAND to the environment. The environment is for variables that are meaningful to all programs. But PROMPT_COMMAND is only useful in bash, so leave it as a shell variable. There's no point in having it be inherited by descendant instances of bash, either: PROMPT_COMMAND is only useful in interactive instances of bash, and they all read .bashrc anyway.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.