LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   crtl-w on tmux naming shells (https://www.linuxquestions.org/questions/linux-newbie-8/crtl-w-on-tmux-naming-shells-4175525900/)

casperdaghost 11-19-2014 12:28 PM

crtl-w on tmux naming shells
 
This is tmux - when i hit 'ctrl -w' which shows me all the
different shells that I have up. This shell casper1005foo
is where i initially log in to the system. Each of these
shells have ssh'd to another host. It would be cool if when
I hit 'ctrl-w' is listed the host the that the shell was
ssh'd into.
Is there a setting in tmux.config or is there a way to rename the
shells. It would be better if I could identify where the shells were
logged into with 'crtl-w'.

[CODE]
(0) 0: bash "casper1005foo"
(1) 1: ssh- "casper1005foo"
(2) 2: ssh* "casper1005foo"
(3) 3: ssh "casper1005foo"
(4) 4: ssh "casper1005foo"
(5) 5: ssh "casper1005foo"
(6) 6: ssh "casper1005foo"
(7) 7: ssh "casper1005foo"
(8) 8: bash "casper1005foo"
[CODE]

corp769 11-19-2014 03:23 PM

I use the preexec function in zsh to do this before hand, see the following:
Code:

function preexec() {
    local a=${${1## *}[(w)1]}
    local b=${a##*\/}
    a="${b}${1#$a}"
    a=${a//\%/\%\%}
    a=$(print -Pn "$a" | tr -d "\t\n\v\f\r")
    a=${(V)a//\%/\%\%}
    a=${a:0:14}
    case "$TERM" in
        screen-256color ) print -Pn "\ek%n@%m:%-3~[$a]\e\\" ;;
    esac
}

I use pretty much the same function/config across all of my machines, but you can use a function in your shell's config (zsh, bash, etc) to do this as well. Found the following doing a quick search, it may suffice for what you are looking for - http://superuser.com/questions/24929...e-ssh-hostname


All times are GMT -5. The time now is 11:17 AM.