Answered my own question. Here's the working line to output to an xterm 
compatible title from inside tmux:
> printf '\ePtmux;\e\e]2;%s\e\e\\' "$*"

Part of the issue was the Mac Terminal's built-in update_terminal_cwd function. 
This sets the URL for the Terminal application's titlebar. It was (incorrectly) 
trying to set the title from inside tmux and breaking my escape sequence above. 
I redefined the function via .bash_profile to handle tmux:
> update_terminal_cwd () { # Update to Mac terminal built-in function for 
> setting title bar URL - handles tmux correctly
>     local SEARCH=' ';
>     local REPLACE='%20';
>       local PWD_URL="file://$(HOSTNAME)${PWD//${SEARCH}/${REPLACE}}";
>     if [[ -z ${TMUX} ]]; then # Not in tmux
>               printf '\e]7;%s\e\\' "${PWD_URL}"
>       else # In tmux
>               printf '\ePtmux;\e\e]7;%s\e\\' "${PWD_URL}"
>       fi
> }

Hopefully this will save the next user some time.

-Adrian

On Nov 17, 2012, at 1:40 PM, Adrian Luff <adr...@luff.me> wrote:

> I'm trying to use escape sequences to set my xterm-title-compabile terminal's 
> title from inside tmux. From a non-tmux shell the following works 
> successfully:
>> echo -ne "\e]2;Title\e\\"
> 
> According to the 1.6 changelog I need to add a DCS sequence (\eP) followed by 
> "tmux" to passthrough escape sequences to the terminal. Searching on this 
> issue I found a reference to escaping escapes for DCS. Doing so yields:
>> echo -e "\ePtmux;\e\e]2;Title\e\e\\"
> 
> This works. However I get output on the screen -- part of my PS1 prompt. I 
> also see a bell signal.I'm guessing the escape sequence isn't being closed 
> correctly.
> 
> I've tried several different combinations (including using \a or \007 instead 
> of \\) to finish the command without success. Can someone tell me how to do 
> this correctly?
> 
> -Adrian
> 
> ------------------------------------------------------------------------------
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from $795 for 25 servers or applications!
> http://p.sf.net/sfu/zoho_dev2dev_nov_______________________________________________
> tmux-users mailing list
> tmux-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tmux-users

Attachment: smime.p7s
Description: S/MIME cryptographic signature

------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to