From eb10329461fe6700f9bed71c677b007596b3f830 Mon Sep 17 00:00:00 2001 From: Xavier Cambar Date: Fri, 31 Jan 2014 13:28:50 +0100 Subject: [PATCH] Prezto's tmux module doesn't override tmux's `destroy-unattached` option --- modules/tmux/README.md | 12 +++++++++--- modules/tmux/init.zsh | 27 +++++++++++---------------- runcoms/zpreztorc | 1 - 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/modules/tmux/README.md b/modules/tmux/README.md index 68ba9d06..90b969bf 100644 --- a/modules/tmux/README.md +++ b/modules/tmux/README.md @@ -23,9 +23,14 @@ following line to *zpreztorc*: In both cases, it will create a background session named _#Prezto_ and attach every new shell to it. -To avoid keeping open sessions, this module sets `destroy-unattached off` on -the background session and `destroy-unattached on` on every other session -(global setting). +To control if the unattached sessions must be kept alive, set the +`destroy-unattached` option in your `.tmux.conf`: + + ```shell + set-option -g destroy-unattached 'on' + # or + set-option -g destroy-unattached 'off' + ``` Aliases ------- @@ -54,6 +59,7 @@ Authors - [Sorin Ionescu](https://github.com/sorin-ionescu) - [Colin Hebert](https://github.com/ColinHebert) - [Georges Discry](https://github.com/gdiscry) + - [Xavier Cambar](https://github.com/xcambar) [1]: http://tmux.sourceforge.net [2]: https://github.com/sorin-ionescu/prezto/issues/62 diff --git a/modules/tmux/init.zsh b/modules/tmux/init.zsh index f7f4c7ed..2c310e47 100644 --- a/modules/tmux/init.zsh +++ b/modules/tmux/init.zsh @@ -5,6 +5,7 @@ # Sorin Ionescu # Colin Hebert # Georges Discry +# Xavier Cambar # # Return if requirements are not found. @@ -22,25 +23,19 @@ 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 - # Ensure that tmux server is started. - tmux start-server - - # Disable the destruction of unattached sessions globally. - tmux set-option -g destroy-unattached off &> /dev/null - - # Create a new session. - tmux new-session -d -s "$tmux_session" - - # Disable the destruction of the new, unattached session. - tmux set-option -t "$tmux_session" destroy-unattached off &> /dev/null - - # Enable the destruction of unattached sessions globally to prevent - # an abundance of open, detached sessions. - tmux set-option -g destroy-unattached on &> /dev/null + tmux start-server \; new-session -d -s "$tmux_session" \; set-option -t "$tmux_session" destroy-unattached off &> /dev/null fi - exec tmux new-session -t "$tmux_session" + #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 + exec tmux attach-session fi # diff --git a/runcoms/zpreztorc b/runcoms/zpreztorc index 80f2a052..a54fdb02 100644 --- a/runcoms/zpreztorc +++ b/runcoms/zpreztorc @@ -152,4 +152,3 @@ zstyle ':prezto:module:prompt' theme 'sorin' # Auto start a session when Zsh is launched in a SSH connection. # zstyle ':prezto:module:tmux:auto-start' remote 'yes' -