Diff
1diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh
2index 4c4e62f54390c79c2d428f654e0a298ab7d77a79..1b97cae7367b5d5baa4f7878c639c95eb92e1cd9 100644
3--- a/plugins/tmux/tmux.plugin.zsh
4+++ b/plugins/tmux/tmux.plugin.zsh
5@@ -11,7 +11,7 @@ alias tkss='tmux kill-session -t'
6
7 # Only run if tmux is actually installed
8 if ! which tmux &> /dev/null; then
9- print "zsh tmux plugin: tmux not found. Please install tmux before using this plugin."
10+ print "zsh tmux plugin: tmux not found. Please install tmux before using this plugin." >&2
11 return 1
12 fi
13
14@@ -40,9 +40,6 @@ fi
15 [[ -n "$ZSH_TMUX_FIXTERM_WITH_256COLOR" ]] || ZSH_TMUX_FIXTERM_WITH_256COLOR="screen-256color"
16
17
18-# Get the absolute path to the current directory
19-local zsh_tmux_plugin_path="$(cd "$(dirname "$0")" && pwd)"
20-
21 # Determine if the terminal supports 256 colors
22 if [[ `tput colors` == "256" ]]; then
23 export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR
24@@ -53,25 +50,33 @@ fi
25 # Set the correct local config file to use.
26 if [[ "$ZSH_TMUX_ITERM2" == "false" ]] && [[ -f $HOME/.tmux.conf || -h $HOME/.tmux.conf ]]; then
27 #use this when they have a ~/.tmux.conf
28- export _ZSH_TMUX_FIXED_CONFIG="$zsh_tmux_plugin_path/tmux.extra.conf"
29+ export _ZSH_TMUX_FIXED_CONFIG="${0:h:a}/tmux.extra.conf"
30 else
31 #use this when they don't have a ~/.tmux.conf
32- export _ZSH_TMUX_FIXED_CONFIG="$zsh_tmux_plugin_path/tmux.only.conf"
33+ export _ZSH_TMUX_FIXED_CONFIG="${0:h:a}/tmux.only.conf"
34 fi
35
36 # Wrapper function for tmux.
37 function _zsh_tmux_plugin_run() {
38- # We have other arguments, just run them
39+ local tmux_cmd
40+ tmux_cmd=(command tmux)
41+ [[ "$ZSH_TMUX_ITERM2" == "true" ]] && tmux_cmd+="-CC"
42+ [[ "$ZSH_TMUX_FIXTERM" == "true" ]] && tmux_cmd+=(-f $_ZSH_TMUX_FIXED_CONFIG)
43 if [[ -n "$@" ]]; then
44+ # We have other arguments, just run them
45 \tmux $@
46- # Try to connect to an existing session.
47 elif [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]]; then
48- \tmux `[[ "$ZSH_TMUX_ITERM2" == "true" ]] && echo '-CC '` attach || \tmux `[[ "$ZSH_TMUX_ITERM2" == "true" ]] && echo '-CC '` `[[ "$ZSH_TMUX_FIXTERM" == "true" ]] && echo '-f '$_ZSH_TMUX_FIXED_CONFIG` new-session
49- [[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] && exit
50- # Just run tmux, fixing the TERM variable if requested.
51+ # Try to connect to an existing session.
52+ $tmux_cmd attach || $tmux_cmd new-session
53+ if [[ "$ZSH_TMUX_AUTOQUIT" == "true" ]]; then
54+ exit
55+ fi
56 else
57- \tmux `[[ "$ZSH_TMUX_ITERM2" == "true" ]] && echo '-CC '` `[[ "$ZSH_TMUX_FIXTERM" == "true" ]] && echo '-f '$_ZSH_TMUX_FIXED_CONFIG`
58- [[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] && exit
59+ # Just run tmux, fixing the TERM variable if requested.
60+ $tmux_cmd
61+ if [[ "$ZSH_TMUX_AUTOQUIT" == "true" ]]; then
62+ exit
63+ fi
64 fi
65 }
66