zprofile: Exit after tmux instead of exec-ing

Instead of exec-ing the tmux process, run it normally and exit
afterwards. Otherwise the zlogout is not read as mentioned a couple of
lines above and in `zsh(1)`:

> However, if the shell terminates due to exec'ing another process, the
> logout files are not read.
This commit is contained in:
2022-04-09 14:22:42 +02:00
parent 3b29820957
commit 15f4bac670

View File

@@ -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=(exec tmux -f "${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf") TMUX_CMD=(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
@@ -122,7 +122,8 @@ then
"${TMUX_CMD[@]}" attach\; choose-tree -Zs "${TMUX_CMD[@]}" attach\; choose-tree -Zs
fi fi
unset TMUX_CMD num_sessions # NOTE: Do not use exec so that the zlogout is still read.
exit $?
fi fi
# NOTE: nothing should be placed behind this except for stuff that is sure that # NOTE: nothing should be placed behind this except for stuff that is sure that
# `tmux` was not called # `tmux` was not called