mirror of https://github.com/bjeanes/dotfiles.git
Simplify Tmux auto-joining
This seems to have changed quite a bit since I was using this regularly (~8 years ago) and in my testing today seems to create a situation where every separate session is bound to the same active window. So, while it created a new tmux window (tab) each time I connected, it unfortunately kept all my Terminal windows/sessions in sync so I couldn't view two different Tmux windows within the same session using two different terminal windows.
parent
e4c38e95d8
commit
70ddba3e45
|
@ -1,19 +1,12 @@
|
|||
# I always want to be in a Tmux session. Always.
|
||||
#
|
||||
# This creates a single always-running "login" session, and creates
|
||||
# new session as needed that are bound to "login"'s window group.
|
||||
# This lets me have a different terminals tabs/windows have the same tmux
|
||||
# windows but be looking at different ones individually
|
||||
# I always want to be in a Tmux session when SSHing into a box.
|
||||
|
||||
# If we aren't in Tmux or emacs, set it up
|
||||
# If we aren't already in Tmux or emacs, set it up
|
||||
if command -v tmux &>/dev/null && [ "$SSH_CONNECTION" -a -z "$TMUX" -a -z "$INSIDE_EMACS" -a -z "$EMACS" -a -z "$VIM" -a -z "$VIMRUNTIME" ]; then
|
||||
if tty >/dev/null; then
|
||||
if [ -z "$(tmux ls | grep 'login:')" ]; then
|
||||
tmux new-session -d -s login # Create a detached session called login
|
||||
tmux new-session -t login # Create a *new* session bound to the same windows
|
||||
if ! tmux has-session -t login 2>/dev/null; then
|
||||
tmux attach-session -t login
|
||||
else
|
||||
last_session="$(tmux list-windows -t login | tail -n1 | cut -d: -f1)"
|
||||
tmux new-session -t login \; new-window -a -t $last_session # Create a *new* session bound to "login" and create a new window
|
||||
tmux new-session -s login
|
||||
fi
|
||||
|
||||
# When Tmux exits, we exit
|
||||
|
|
Loading…
Reference in New Issue