86b39cfa0a42cd0962be2b8072e73229280c362b

Author
StelFux <22601105+StelFux@users.noreply.github.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

tmux: allow to define a custom configuration path (#7606)

Diff

 1diff --git a/plugins/tmux/README.md b/plugins/tmux/README.md
 2index e887ceebb277e348f5a4b882eb008bd9021da5b3..1e25af38fca52abe23a8620a5615a5f5144a0b53 100644
 3--- a/plugins/tmux/README.md
 4+++ b/plugins/tmux/README.md
 5@@ -37,3 +37,4 @@ The plugin also supports the following -
 6 | `ZSH_TMUX_ITERM2`                   | Sets the `-CC` option for iTerm2 tmux integration (default: `false`)          |
 7 | `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `screen`)                |
 8 | `ZSH_TMUX_FIXTERM_WITH_256COLOR`    | `$TERM` to use for 256-color terminals (default: `screen-256color`            |
 9+| `ZSH_TMUX_CONFIG`                   | Set the configuration path (default: `$HOME/.tmux.conf`)                      |
10diff --git a/plugins/tmux/tmux.extra.conf b/plugins/tmux/tmux.extra.conf
11index beffd380c43077053ebf193475b4c1982722103a..3420d19d4324c0fca0c3ed138e5bbf13ce5f666a 100644
12--- a/plugins/tmux/tmux.extra.conf
13+++ b/plugins/tmux/tmux.extra.conf
14@@ -1,2 +1,2 @@
15 set -g default-terminal $ZSH_TMUX_TERM
16-source $HOME/.tmux.conf
17+source $ZSH_TMUX_CONFIG
18diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh
19index 2f3c3e79dcfec8282cde752cc530418babb97b36..d7b29969073c7c128036e8fb4cdf2ae457efe0ea 100644
20--- a/plugins/tmux/tmux.plugin.zsh
21+++ b/plugins/tmux/tmux.plugin.zsh
22@@ -34,6 +34,8 @@ alias tkss='tmux kill-session -t'
23 # Tmux states this should be screen-256color, but you may need to change it on
24 # systems without the proper terminfo
25 : ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=screen-256color}
26+# Set the configuration path
27+: ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
28 
29 # Determine if the terminal supports 256 colors
30 if [[ $terminfo[colors] == 256 ]]; then
31@@ -43,7 +45,7 @@ else
32 fi
33 
34 # Set the correct local config file to use.
35-if [[ "$ZSH_TMUX_ITERM2" == "false" && -e "$HOME/.tmux.conf" ]]; then
36+if [[ "$ZSH_TMUX_ITERM2" == "false" && -e "$ZSH_TMUX_CONFIG" ]]; then
37   export _ZSH_TMUX_FIXED_CONFIG="${0:h:a}/tmux.extra.conf"
38 else
39   export _ZSH_TMUX_FIXED_CONFIG="${0:h:a}/tmux.only.conf"
40@@ -65,8 +67,9 @@ function _zsh_tmux_plugin_run() {
41 
42   # If failed, just run tmux, fixing the TERM variable if requested.
43   if [[ $? -ne 0 ]]; then
44-    [[ "$ZSH_TMUX_FIXTERM" == "true" ]] && tmux_cmd+=(-f "$_ZSH_TMUX_FIXED_CONFIG")
45-    $tmux_cmd new-session
46+    [[ "$ZSH_TMUX_FIXTERM" == "true" ]] && tmux_cmd+=(-f "$_ZSH_TMUX_FIXED_CONFIG") || \
47+    [[ -e "$ZSH_TMUX_CONFIG" ]] && tmux_cmd+=(-f "$ZSH_TMUX_CONFIG")
48+    $tmux_cmd new-session  
49   fi
50 
51   if [[ "$ZSH_TMUX_AUTOQUIT" == "true" ]]; then