mbm329 <mbm...@gmail.com> wrote:
> Hello list,
> 
> I'm trying to transition from GNU Screen to tmux.  I like to have my
> windows named as the host they are logged into.  That is, until I run
> a command.  Then I like to have it named for the command I'm running.
> 
> In GNU Screen, I accomplished this via the PS1 environment variable.
> (some shells in various OSes do not support PROMPT_COMMAND)
> 
> In Linux:
> export PS1="\[\033]0;${USER}@${HOSTNAME}\007\]"  ##display user@host
> in titlebar or "%h" screen string escape
> export PS1=${PS1}'\[\033k\033\\\]'  ##display running command for
> window name in screen's caption line (empty the current name)
> export PS1=${PS1}'\[\033k'${HOSTNAME}'\033\\\]'  ##show hostname for
> window name on screen's caption line when idle
> export PS1='<\u@\h:\w>\n'${PS1}'\$ '
> 
> I place this code in my .bashrc or .profile of each host I ssh into.
> It works great in screen.
> 
> When I try this in tmux, it sets the window name (#W) to the hostname
> of the system i'm logged into great, but it fails to set it to a
> running command (example: top, sar, etc...)
> 
> I believe this is due to the fact that I tell screen what a prompt
> looks like via this config:
> shelltitle "$ |idle"
> 
> I'm not quite sure how to accomplish this with tmux.  I have tried
> setw -g automatic-rename on, but from what I've read, after the first
> rename (my PS1 being set), it disables this feature for the window.
> 
> Can anyone provide any ideas or solutions that will acknowledge the
> escape sequence I'm using for setting the window, yet override it when
> a command is run?  Perhaps there is a config directive I'm
> overlooking.  Perhaps there's something even easier and cleaner than
> setting PS1 on every host; that would be nice.

I use the following setting:

    set-window-option -g window-status-format '#I#F:#T-#W'

which looks something like:

    1#:-python

by default. When ssh'ing I've seen it become:

    1#:user@host-bash

I've also seen that tmux is much better at grabbing the process name
than screen (ENVVAR=value cmd is 'ENVVAR=value' in screen and 'cmd' in
tmux) but it doesn't get things that run under interpreters that well
(offlineimap is 'python', for instance). Don't have any machines to ssh
into at the moment however to verify the auto-hosting right now. I also
have the following function in my zshrc:

    tmux_title () {
        if [ -n "$TMUX" ]; then
            printf "\033]2;$1\033\\"
        fi
    }


    # Initialize to nothing
    if [[ -z "$VIMRUNTIME" ]]; then
        tmux_title ""
    fi

To manually name shells and to clear it on new (local) shells that are
not from vim (:sh).

Hope this helps.

--Ben


------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to