feat(tmux): allow all standard config files (#11103)
Closes #11803
Co-authored-by: n0tr00t <106423923+n0tr00teuorg@users.noreply.github.com>
Diff
1diff --git a/plugins/tmux/README.md b/plugins/tmux/README.md
2index 7348f77c942210654589c1b43722ac9083e6a7da..0f8473daf45c6fb0d0320349a5f8337a4e7db358 100644
3--- a/plugins/tmux/README.md
4+++ b/plugins/tmux/README.md
5@@ -28,16 +28,16 @@ The plugin also supports the following:
6 7 ## Configuration Variables
8 9-| Variable | Description |
10-| ----------------------------------- | ----------------------------------------------------------------------------- |
11-| `ZSH_TMUX_AUTOSTART` | Automatically starts tmux (default: `false`) |
12-| `ZSH_TMUX_AUTOSTART_ONCE` | Autostart only if tmux hasn't been started previously (default: `true`) |
13-| `ZSH_TMUX_AUTOCONNECT` | Automatically connect to a previous session if it exits (default: `true`) |
14-| `ZSH_TMUX_AUTOQUIT` | Automatically closes terminal once tmux exits (default: `ZSH_TMUX_AUTOSTART`) |
15-| `ZSH_TMUX_FIXTERM` | Sets `$TERM` to 256-color term or not based on current terminal support |
16-| `ZSH_TMUX_ITERM2` | Sets the `-CC` option for iTerm2 tmux integration (default: `false`) |
17-| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `screen`) |
18-| `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `screen-256color` |
19-| `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`) |
20-| `ZSH_TMUX_UNICODE` | Set `tmux -u` option to support unicode |
21-| `ZSH_TMUX_DEFAULT_SESSION_NAME` | Set tmux default session name when autostart is enabled |
22+| Variable | Description |
23+| ----------------------------------- | ------------------------------------------------------------------------------------------- |
24+| `ZSH_TMUX_AUTOSTART` | Automatically starts tmux (default: `false`) |
25+| `ZSH_TMUX_AUTOSTART_ONCE` | Autostart only if tmux hasn't been started previously (default: `true`) |
26+| `ZSH_TMUX_AUTOCONNECT` | Automatically connect to a previous session if it exits (default: `true`) |
27+| `ZSH_TMUX_AUTOQUIT` | Automatically closes terminal once tmux exits (default: `ZSH_TMUX_AUTOSTART`) |
28+| `ZSH_TMUX_FIXTERM` | Sets `$TERM` to 256-color term or not based on current terminal support |
29+| `ZSH_TMUX_ITERM2` | Sets the `-CC` option for iTerm2 tmux integration (default: `false`) |
30+| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `screen`) |
31+| `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `screen-256color` |
32+| `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`, `$XDG_CONFIG_HOME/tmux/tmux.conf`) |
33+| `ZSH_TMUX_UNICODE` | Set `tmux -u` option to support unicode |
34+| `ZSH_TMUX_DEFAULT_SESSION_NAME` | Set tmux default session name when autostart is enabled |
35diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh
36index 311c2e6a9b5e3c1ee7d00cd2548443746e1b1260..680f72598b723b60ae0ce49c2a94abf72a8b9823 100644
37--- a/plugins/tmux/tmux.plugin.zsh
38+++ b/plugins/tmux/tmux.plugin.zsh
39@@ -26,12 +26,17 @@ fi
40 # systems without the proper terminfo
41 : ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=screen-256color}
42 # Set the configuration path
43-: ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
44+if [[ -e $HOME/.tmux.conf ]]; then
45+ : ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
46+elif [[ -e ${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf ]]; then
47+ : ${ZSH_TMUX_CONFIG:=${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf}
48+else
49+ : ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
50+fi
51 # Set -u option to support unicode
52 : ${ZSH_TMUX_UNICODE:=false}
5354 # ALIASES
55-
56 alias ta='tmux attach -t'
57 alias tad='tmux attach -d -t'
58 alias ts='tmux new-session -s'