diff --git a/modules/tmux/README.md b/modules/tmux/README.md index 5901c7ce..8d291a82 100644 --- a/modules/tmux/README.md +++ b/modules/tmux/README.md @@ -20,8 +20,8 @@ following line to *zpreztorc*: zstyle ':prezto:module:tmux:auto-start' remote 'yes' -In both cases, it will create a background session named _#Prezto_ and attach -every new shell to it. +In both cases, it will create a background session named _prezto_ if the tmux +server is not started. __Note__: With `auto-start` enabled, you may want to control how multiple sessions are managed. The `destroy-unattached` option of tmux controls if the diff --git a/modules/tmux/init.zsh b/modules/tmux/init.zsh index 2c310e47..de53afe2 100644 --- a/modules/tmux/init.zsh +++ b/modules/tmux/init.zsh @@ -23,18 +23,12 @@ if [[ -z "$TMUX" && ( -z "$INSIDE_EMACS" || -z "$EMACS" || -z "$VIM" ) ]] && ( \ ); then tmux_session='prezto' - # Create the default '#Prezto' session if not available. - if ! tmux has-session -t "$tmux_session" 2> /dev/null; then + # Create a first 'prezto' session if tmux is starting. + if ! tmux has-session 2> /dev/null; then tmux start-server \; new-session -d -s "$tmux_session" \; set-option -t "$tmux_session" destroy-unattached off &> /dev/null fi - #By default, prezto sets destroy-unattached to on - tmux_destroy_unattached=`tmux show-options -v -g destroy-unattached` - if [[ -z "$tmux_destroy_unattached" ]]; then - tmux set-option -g destroy-unattached on - fi - - #Opens the session '#Prezto' or the latest session used + #Opens the session 'prezto' or the latest session used exec tmux attach-session fi