26ee66f179be08fab59d41a0522ad51610125c6c
- Author
- Josh Matthews <jmatth@nbcs.rutgers.edu>
- Committer
- Josh Matthews <jmatth@nbcs.rutgers.edu>
- Date
Message
Adding main function and alias to tmux plugin.
Diff
1diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh
2index cc676cb92f5a04cf6eb0bc21c7f93b4fc0cc9d9d..a2f36c0be01e007712d252a084e88baebc16efbf 100644
3--- a/plugins/tmux/tmux.plugin.zsh
4+++ b/plugins/tmux/tmux.plugin.zsh
5@@ -1,12 +1,41 @@
6 # Configuration variables
7 # Automatically start tmux
8-[[ -n "$ZSH_TMUX_AUTOSTART" ]] || ZSH_TMUX_AUTOSTART = false
9+[[ -n "$ZSH_TMUX_AUTOSTART" ]] || ZSH_TMUX_AUTOSTART=false
10 # Automatically connect to a previous session if it exists
11-[[ -n "$ZSH_TMUX_AUTOCONNECT" ]] || ZSH_TMUX_AUTOCONNECT = true
12+[[ -n "$ZSH_TMUX_AUTOCONNECT" ]] || ZSH_TMUX_AUTOCONNECT=true
13 # Automatically close the terminal when tmux exits
14-[[ -n "$ZSH_TMUX_AUTOQUIT" ]] || ZSH_TMUX_AUTOQUIT = true
15+[[ -n "$ZSH_TMUX_AUTOQUIT" ]] || ZSH_TMUX_AUTOQUIT=$ZSH_TMUX_AUTOSTART
16 # Set term to screen or screen-256color based on current terminal support
17-[[ -n "$ZSH_TMUX_FIXTERM" ]] || ZSH_TMUX_AUTOCONNECT = true
18+[[ -n "$ZSH_TMUX_FIXTERM" ]] || ZSH_TMUX_AUTOCONNECT=true
19
20 # Get the absolute path to the current directory
21 local zsh_tmux_plugin_path="$(cd "$(dirname "$0")" && pwd)"
22+
23+# Local variable to store the local config file to use, if any.
24+local fixed_config=""
25+
26+# Set the correct local config file to use
27+if [[ "$ZSH_TMUX_FIXTERM" == "true" ]]
28+then
29+ if [[ -f $HOME/.tmux.conf || -h $HOME/.tmux.conf ]]
30+ then
31+ fixed_config=$zsh_tmux_plugin_path/tmux.extra.conf
32+ else
33+ fixed_config=$zsh_tmux_plugin_path/tmux.only.conf
34+ fi
35+fi
36+
37+# Override tmux with our function
38+function zsh_tmux_plugin_start()
39+{
40+ if [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]]
41+ then
42+ \tmux attach || tmux -f $fixed_config new-session
43+ [[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] && exit
44+ else
45+ \tmux -f $fixed_config
46+ [[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] && exit
47+ fi
48+}
49+
50+alias tmux=zsh_tmux_plugin_start