title: why isn't my bash prompt properly escaping?
body: <p>I have the following bash prompt variable, defined in my .basrhc file:</p>
  
  <p><code>PS1='\u@\h:\[\e[01;34m\] \[$(pwd|sed -e "s!.*/\\([^/]*/[^/]*/[^/]*\\)!\\1!g")\] \[\e[00m\] \[\e[01;31m\]\t\[\e[00m\]\$ '</code></p>
  
  <p>From a directory, /one/two/three/four/, this would look like a colourised version of:</p>
  
  <p><code>me@my-computer two/three/four 12:01:37$</code></p>
  
  <p>(I wan't to put an image of what I get, but I'm a newcomer with no rep points..) </p>
  
  <p>I'm having problems with it not being escaped properly (I think this is the source) in that, when scrolling up through my history, the lines truncate the bash prompt, and the terminal doesn't display the cursor in the correct place of the command line.  You may have to scroll up a fair few lines before this effect is seen though.</p>
  
  <p>I think the problem is the <code>sed</code> command but I'm not sure how to resolve it if that's right.<br>
  Any thoughts?</p>