zprofile: Use exec when attaching to tmux
When connected over ssh and attaching to/creating a tmux session, the
shell should `exec` the tmux command so that detaching from the session
automatically also closes the ssh connection.
If something should happen and the `tmux` command bricks the remote
shell this can fixed by logging in with:
ssh [destination] zsh -dfi
This commit is contained in:
@@ -111,7 +111,7 @@ fi
|
|||||||
if (( $+commands[tmux] )) &&
|
if (( $+commands[tmux] )) &&
|
||||||
[[ (-n $SSH_CLIENT || -n $SSH_TTY || -n $SSH_CONNECTION) && -z $TMUX ]]
|
[[ (-n $SSH_CLIENT || -n $SSH_TTY || -n $SSH_CONNECTION) && -z $TMUX ]]
|
||||||
then
|
then
|
||||||
TMUX_CMD=(tmux -f "${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf")
|
TMUX_CMD=(exec tmux -f "${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf")
|
||||||
num_sessions="$("${TMUX_CMD[@]}" list-sessions 2>/dev/null | wc -l)"
|
num_sessions="$("${TMUX_CMD[@]}" list-sessions 2>/dev/null | wc -l)"
|
||||||
|
|
||||||
if (( ! num_sessions )); then
|
if (( ! num_sessions )); then
|
||||||
@@ -124,3 +124,5 @@ then
|
|||||||
|
|
||||||
unset TMUX_CMD num_sessions
|
unset TMUX_CMD num_sessions
|
||||||
fi
|
fi
|
||||||
|
# NOTE: nothing should be placed behind this except for stuff that is sure that
|
||||||
|
# `tmux` was not called
|
||||||
|
|||||||
Reference in New Issue
Block a user