Diff
1diff --git a/plugins/tmux/README.md b/plugins/tmux/README.md
2index b4516ef2657a4d365abb64cbea950a7443dd511d..a253457f2b803da7e5204fe4bec7bbfd19c9891c 100644
3--- a/plugins/tmux/README.md
4+++ b/plugins/tmux/README.md
5@@ -19,13 +19,13 @@ The plugin also supports the following:
6 | ---------- | -------------------------- | -------------------------------------------------------- |
7 | `ta` | tmux attach -t | Attach new tmux session to already running named session |
8 | `tad` | tmux attach -d -t | Detach named tmux session |
9-| `ts` | tmux new-session -s | Create a new named tmux session |
10-| `tl` | tmux list-sessions | Displays a list of running tmux sessions |
11-| `tksv` | tmux kill-server | Terminate all running tmux sessions |
12+| `tds` | `_tmux_directory_session` | Creates or attaches to a session for the current path |
13 | `tkss` | tmux kill-session -t | Terminate named running tmux session |
14+| `tksv` | tmux kill-server | Terminate all running tmux sessions |
15+| `tl` | tmux list-sessions | Displays a list of running tmux sessions |
16 | `tmux` | `_zsh_tmux_plugin_run` | Start a new tmux session |
17 | `tmuxconf` | `$EDITOR $ZSH_TMUX_CONFIG` | Open .tmux.conf file with an editor |
18-| `tds` | `_tmux_directory_session` | Creates or attaches to a session for the current path |
19+| `ts` | tmux new-session -s | Create a new named tmux session |
20
21 ## Configuration Variables
22
23@@ -35,10 +35,11 @@ The plugin also supports the following:
24 | `ZSH_TMUX_AUTOSTART_ONCE` | Autostart only if tmux hasn't been started previously (default: `true`) |
25 | `ZSH_TMUX_AUTOCONNECT` | Automatically connect to a previous session if it exits (default: `true`) |
26 | `ZSH_TMUX_AUTOQUIT` | Automatically closes terminal once tmux exits (default: `ZSH_TMUX_AUTOSTART`) |
27+| `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`, `$XDG_CONFIG_HOME/tmux/tmux.conf`) |
28+| `ZSH_TMUX_DEFAULT_SESSION_NAME` | Set tmux default session name when autostart is enabled |
29+| `ZSH_TMUX_DETACHED` | Set the detached mode (default: `false`) |
30 | `ZSH_TMUX_FIXTERM` | Sets `$TERM` to 256-color term or not based on current terminal support |
31-| `ZSH_TMUX_ITERM2` | Sets the `-CC` option for iTerm2 tmux integration (default: `false`) |
32 | `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `screen`) |
33 | `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `screen-256color` |
34-| `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`, `$XDG_CONFIG_HOME/tmux/tmux.conf`) |
35+| `ZSH_TMUX_ITERM2` | Sets the `-CC` option for iTerm2 tmux integration (default: `false`) |
36 | `ZSH_TMUX_UNICODE` | Set `tmux -u` option to support unicode |
37-| `ZSH_TMUX_DEFAULT_SESSION_NAME` | Set tmux default session name when autostart is enabled |
38diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh
39index 72cdd481830b799c723904d73ae95c79e6d89dcd..0ecb0a5b5a5cd697962bb1d1654d0c8d1276ffb1 100644
40--- a/plugins/tmux/tmux.plugin.zsh
41+++ b/plugins/tmux/tmux.plugin.zsh
42@@ -14,6 +14,8 @@ fi
43 # Automatically close the terminal when tmux exits
44 : ${ZSH_TMUX_AUTOQUIT:=$ZSH_TMUX_AUTOSTART}
45 # Set term to screen or screen-256color based on current terminal support
46+: ${ZSH_TMUX_DETACHED:=false}
47+# Set detached mode
48 : ${ZSH_TMUX_FIXTERM:=true}
49 # Set '-CC' option for iTerm2 tmux integration
50 : ${ZSH_TMUX_ITERM2:=false}
51@@ -79,9 +81,9 @@ function _zsh_tmux_plugin_run() {
52
53 # Try to connect to an existing session.
54 if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then
55- [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach -t $ZSH_TMUX_DEFAULT_SESSION_NAME
56+ [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach ${ZSH_TMUX_DETACHED:+"-d"} -t $ZSH_TMUX_DEFAULT_SESSION_NAME
57 else
58- [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach
59+ [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach ${ZSH_TMUX_DETACHED:+"-d"}
60 fi
61
62 # If failed, just run tmux, fixing the TERM variable if requested.