9.2. Loading a Different Prompt, Immediately

You can change the prompt in your current terminal (using the example "elite" function shown previously) by typing source elite followed by elite (assuming that the elite function file is the working directory). This is somewhat cumbersome, and leaves you with an extra function (elite) in your environment space - if you want to clean up the environment, you would have to type unset elite as well. This would seem like an ideal candidate for a small shell script, but a script doesn't work here because the script cannot change the environment of your current shell: it can only change the environment of the subshell it runs in. As soon as the script stops, the subshell goes away, and the changes the script made to the environment are gone. What can change environment variables of your current shell are environment functions. I use a function that's loaded from my ~/.bashrc along with my initial prompt:

promnow () 
if [ $# -ne 1 ]
  echo "promnow PROMPTNAME"
  echo "You must supply one prompt name."
  echo "Available prompts are:"
  ls ${PROMPT_DIR}
  source ${PROMPT_DIR}${prom_name}
  unset ${prom_name}

Again: for this to work, the prompt files must contain a function that has the same name as the file they're stored in, and they all need to be stored in (in my case - you'll need to change this filename) /home/giles/.bashprompt/bashthemes/.