I had this requirement also, and found such a solution by creating below
ssh function in my .bashrc

function on_exit(){
    printf "\033kbash\033\\"
    tmux set-window-option automatic-rename on  >/dev/null 2>&1
    trap - SIGINT SIGTERM
}

function ssh() {
    if [ $TERM = "screen-256" ];then
        trap on_exit SIGINT SIGTERM
        a=${1##*@};
        printf "\033k$a\033\\"
        /usr/bin/ssh $@
        printf "\033kbash\033\\"
    else
        /usr/bin/ssh $@
    fi
    tmux set-window-option automatic-rename on  >/dev/null 2>&1
}

2018-01-08 21:04 GMT+08:00 liuyuanting1209 <liuyuanting1...@163.com>:

>
> got it. thanks very much.
>
> thanks,
> Sean Liu
>
>
>
> At 2018-01-07 22:25:30, "Nicholas Marriott" <nicholas.marri...@gmail.com>
> wrote:
>
> There are two ways to do this:
>
> - You can turn on allow-rename and then use the rename window escape
> sequences (\033k...\033\\) to rename the window from the remote host (say
> in your .profile), for example: printf "\033k$(hostname -s)\033\\\\"
>
> - You can write a script to do this from the local machine either using
> the same escape sequence, using tmux renamew, or putting it in say a user
> variable or environment variable that you can access from
> window-status-format, then aliasing that script to ssh.
>
>
>
>
> On 7 January 2018 at 14:06, liuyuanting1209 <liuyuanting1...@163.com>
> wrote:
>
>> Hi,
>>
>> I want to change the window name to the remote ssh-to-host name. But I
>> failed to find the way. host or host_short only show's the local "host"
>> name. Could you please help to tell me the method. Thanks a lot.
>>
>> Thanks,
>> Sean Liu
>>
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "tmux-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to tmux-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to tmux-users@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "tmux-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to tmux-users+unsubscr...@googlegroups.com.
> To post to this group, send email to tmux-users@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
woosley.xu.    http://twitter.com/redicaps

-- 
You received this message because you are subscribed to the Google Groups 
"tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tmux-users+unsubscr...@googlegroups.com.
To post to this group, send an email to tmux-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to