I would like tmux
to create a new-window when I ssh onto a machine from an existing tmux session. However, I do not want a tmux session started on the new machine!
I have the following in my .bashrc
, so that tmux
automatically starts up:
if [[ "$TERM" != "screen" ]]
then
# try to attach to existing session, or start a new one
tmux attach-session -t "$USER" || tmux -2 new-session -s "$USER"
exit
fi
I also have an ssh
function:
alias ssh='ssh_func'
ssh_func (){
if [[ "$TERM" == "screen" ]]; then
tmux new-window -n "$1" "ssh $@";
else
/usr/bin/ssh "$@";
fi
}
This works ok, but I do not want a tmux session started on the machine I ssh to, because this gives me 2 sessions in the same terminal window. Is there anything I can put in my .bashrc
so that tmux does not start up on a machine if the ssh command has been invoked from a tmux session?
I am using PuTTY and tmux 1.5.
$TERM = screen
, so you won't be trying to attach to a tmux window. How does that differ from what you want?TERM=screen
. I getTERM=linux
. It doesn't seem to get exported.TERM
after ssh'ing, there's something wrong with your setup. As far as I can tell the code you posted should do what you want on a normal setup. You need to investigate what is mangling$TERM
. Do you have any code that sets it in~/.ssh/*
or in~/.*
or in/etc/*
?