title: Dynamically change hostname in Bash PS1 prompt
body: <p>I have a bash prompt that includes my hostname using either the <code>\h</code> variable (interpreted by <code>PS1</code>) or <code>$(uname -n)</code>. Whichever one I use doesn't seem to make a difference.</p>
  
  <p>For software licensing reasons, I sometimes have to change my hostname, which is done by calling a script that updates files <code>/etc/hosts</code> and <code>/etc/hostname</code>, and also calls <code>$ hostname NEWNAME</code> for good measure.</p>
  
  <p>When the script updates my hostname, I would like the shell which invoked the script to have its <code>PS1</code> prompt reflect the change -- to show the new hostname. The only way I know to do this is by resourcing my <code>.bashrc</code> which defines <code>PS1</code>. But calling <code>. "${HOME}/.bashrc"</code> within the script is only going to modify that script's environment and not the caller's, as I understand it. </p>
  
  <p>So how can I get the caller's <code>PS1</code> prompt updated as well to show the new hostname automatically?</p>