summaryrefslogtreecommitdiff
path: root/plugins/tmux/tmux.plugin.zsh
diff options
context:
space:
mode:
authorJosh Matthews <jmatth@nbcs.rutgers.edu>2013-02-26 22:18:36 -0500
committerJosh Matthews <jmatth@nbcs.rutgers.edu>2013-02-26 22:29:26 -0500
commit691630a89586c86dfafa32974c5c6dbaa1356c07 (patch)
treefbdd1e81d0f1da6afbe1705a5a3360401742f0cb /plugins/tmux/tmux.plugin.zsh
parentf096644c751cb7fe566e82de531435a405d76be8 (diff)
downloadzsh-691630a89586c86dfafa32974c5c6dbaa1356c07.tar.gz
zsh-691630a89586c86dfafa32974c5c6dbaa1356c07.tar.bz2
zsh-691630a89586c86dfafa32974c5c6dbaa1356c07.zip
Adding option to prevent autostarting tmux more than once in the same session.
Diffstat (limited to 'plugins/tmux/tmux.plugin.zsh')
-rw-r--r--plugins/tmux/tmux.plugin.zsh13
1 files changed, 12 insertions, 1 deletions
diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh
index 8bdd92133..a7bf93dbd 100644
--- a/plugins/tmux/tmux.plugin.zsh
+++ b/plugins/tmux/tmux.plugin.zsh
@@ -1,6 +1,10 @@
# Configuration variables
+#
# Automatically start tmux
[[ -n "$ZSH_TMUX_AUTOSTART" ]] || ZSH_TMUX_AUTOSTART=false
+# Only autostart once. If set to false, tmux will attempt to
+# autostart every time your zsh configs are reloaded.
+[[ -n "$ZSH_TMUX_AUTOSTART_ONCE" ]] || ZSH_TMUX_AUTOSTART_ONCE=true
# Automatically connect to a previous session if it exists
[[ -n "$ZSH_TMUX_AUTOCONNECT" ]] || ZSH_TMUX_AUTOCONNECT=true
# Automatically close the terminal when tmux exits
@@ -8,6 +12,7 @@
# Set term to screen or screen-256color based on current terminal support
[[ -n "$ZSH_TMUX_FIXTERM" ]] || ZSH_TMUX_FIXTERM=true
+
# Get the absolute path to the current directory
local zsh_tmux_plugin_path="$(cd "$(dirname "$0")" && pwd)"
@@ -54,7 +59,13 @@ function zsh_tmux_plugin_run()
# Alias tmux to our wrapper function.
alias tmux=zsh_tmux_plugin_start
+# Autostart if not already in tmux and enabled.
if [[ ! -n "$TMUX" && "$ZSH_TMUX_AUTOSTART" == "true" ]]
then
- zsh_tmux_plugin_run
+ # Actually don't autostart if we already did and multiple autostarts are disabled.
+ if [[ "$ZSH_TMUX_AUTOSTART_ONCE" == "false" || "$ZSH_TMUX_AUTOSTARTED" != "true" ]]
+ then
+ export ZSH_TMUX_AUTOSTARTED=true
+ zsh_tmux_plugin_run
+ fi
fi