simplify things by using PROMPT_COMMAND. How did I miss this before?