robbyrussell/oh-my-zsh — pull request #2429 by drbo (2014-01-14 06:18:30+00:00)
Title: Fix escaping for terminal window and tab titles

This mostly fixes the handling of terminal window and tab titles if the command entered contains \, %, $, `, or !. It handles the options PROMPT_SUBST, PROMPT_BANG, and PROMPT_PERCENT correctly.

The one remaining bug is that the command "echo \!" (and similar) are incorrectly shown as "echo !", not "echo \!". However, I believe that this is a ZSH bug.

It is possible that oh-my-zsh assumes that PROMPT_SUBST and PROMPT_PERCENT are set. In this case, the checks for them can be omitted, and some of the parameter expansions may be able to be combined.

Prior to this, the command a=`date %s%N` would lead to problems, such as parse errors.