From 15f4bac67078bb47039e5ae5f819a7ed92cc6780 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Sat, 9 Apr 2022 14:22:42 +0200 Subject: [PATCH] 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. --- .config/zsh/.zprofile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.config/zsh/.zprofile b/.config/zsh/.zprofile index e18df00..81edf73 100644 --- a/.config/zsh/.zprofile +++ b/.config/zsh/.zprofile @@ -111,7 +111,7 @@ fi if (( $+commands[tmux] )) && [[ (-n $SSH_CLIENT || -n $SSH_TTY || -n $SSH_CONNECTION) && -z $TMUX ]] 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)" if (( ! num_sessions )); then @@ -122,7 +122,8 @@ then "${TMUX_CMD[@]}" attach\; choose-tree -Zs fi - unset TMUX_CMD num_sessions + # NOTE: Do not use exec so that the zlogout is still read. + exit $? fi # NOTE: nothing should be placed behind this except for stuff that is sure that # `tmux` was not called