title: how to show current command in tmux pane title
body: <p>I would like to update the tmux pane-title with the current executing command or, if no command, the name of the current shell. What I've come up with so far is this, in bashrc:</p>
  
  <pre><code>case ${TERM} in
  
    screen*)       
      PROMPT_COMMAND='printf "\033]2;bash\033\\"'
      set -o functrace
      trap 'echo -ne "\033]2;$BASH_COMMAND\033\\"' DEBUG
      ;;
  
     ...
  
  esac
  </code></pre>
  
  <p>the method was derived from here:
  <a href="http://www.davidpashley.com/articles/xterm-titles-with-bash.html" rel="noreferrer">http://www.davidpashley.com/articles/xterm-titles-with-bash.html</a></p>
  
  <p>This partially works - it does what is needed but causes other problems: the first prompt in a new shell is prefixed with </p>
  
  <pre><code>"'"' DEBUG"
  </code></pre>
  
  <p>and all remaining commands with</p>
  
  <pre><code>"
  </code></pre>
  
  <p>It also prevents some commands given on the command line to fail, for example:</p>
  
  <pre><code>$ ps -h $$
  Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
  </code></pre>
  
  <p>So, while the above does allow the current command to be displayed in the tmux pane title, it does not work. Has anyone else got a better solution to this, or a suggestion as to what is wrong with the above?</p>
  
  <p>Thanks.</p>