tmux: detabify source code
Also changes the tmux detection test to do an early exit if tmux is absent, to reduce the indentation level of the main body of code.
This commit is contained in:
parent
b05ef1034f
commit
cd3858cf0e
@ -9,8 +9,11 @@ alias tksv='tmux kill-server'
|
|||||||
alias tkss='tmux kill-session -t'
|
alias tkss='tmux kill-session -t'
|
||||||
|
|
||||||
# Only run if tmux is actually installed
|
# Only run if tmux is actually installed
|
||||||
if which tmux &> /dev/null
|
if ! which tmux &> /dev/null; then
|
||||||
then
|
print "zsh tmux plugin: tmux not found. Please install tmux before using this plugin."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Configuration variables
|
# Configuration variables
|
||||||
#
|
#
|
||||||
# Automatically start tmux
|
# Automatically start tmux
|
||||||
@ -40,16 +43,14 @@ if which tmux &> /dev/null
|
|||||||
local zsh_tmux_plugin_path="$(cd "$(dirname "$0")" && pwd)"
|
local zsh_tmux_plugin_path="$(cd "$(dirname "$0")" && pwd)"
|
||||||
|
|
||||||
# Determine if the terminal supports 256 colors
|
# Determine if the terminal supports 256 colors
|
||||||
if [[ `tput colors` == "256" ]]
|
if [[ `tput colors` == "256" ]]; then
|
||||||
then
|
|
||||||
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR
|
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR
|
||||||
else
|
else
|
||||||
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITHOUT_256COLOR
|
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITHOUT_256COLOR
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set the correct local config file to use.
|
# Set the correct local config file to use.
|
||||||
if [[ "$ZSH_TMUX_ITERM2" == "false" ]] && [[ -f $HOME/.tmux.conf || -h $HOME/.tmux.conf ]]
|
if [[ "$ZSH_TMUX_ITERM2" == "false" ]] && [[ -f $HOME/.tmux.conf || -h $HOME/.tmux.conf ]]; then
|
||||||
then
|
|
||||||
#use this when they have a ~/.tmux.conf
|
#use this when they have a ~/.tmux.conf
|
||||||
export _ZSH_TMUX_FIXED_CONFIG="$zsh_tmux_plugin_path/tmux.extra.conf"
|
export _ZSH_TMUX_FIXED_CONFIG="$zsh_tmux_plugin_path/tmux.extra.conf"
|
||||||
else
|
else
|
||||||
@ -58,15 +59,12 @@ if which tmux &> /dev/null
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Wrapper function for tmux.
|
# Wrapper function for tmux.
|
||||||
function _zsh_tmux_plugin_run()
|
function _zsh_tmux_plugin_run() {
|
||||||
{
|
|
||||||
# We have other arguments, just run them
|
# We have other arguments, just run them
|
||||||
if [[ -n "$@" ]]
|
if [[ -n "$@" ]]; then
|
||||||
then
|
|
||||||
\tmux $@
|
\tmux $@
|
||||||
# Try to connect to an existing session.
|
# Try to connect to an existing session.
|
||||||
elif [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]]
|
elif [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]]; then
|
||||||
then
|
|
||||||
\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
|
\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
|
||||||
[[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] && exit
|
[[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] && exit
|
||||||
# Just run tmux, fixing the TERM variable if requested.
|
# Just run tmux, fixing the TERM variable if requested.
|
||||||
@ -83,15 +81,10 @@ if which tmux &> /dev/null
|
|||||||
alias tmux=_zsh_tmux_plugin_run
|
alias tmux=_zsh_tmux_plugin_run
|
||||||
|
|
||||||
# Autostart if not already in tmux and enabled.
|
# Autostart if not already in tmux and enabled.
|
||||||
if [[ ! -n "$TMUX" && "$ZSH_TMUX_AUTOSTART" == "true" ]]
|
if [[ ! -n "$TMUX" && "$ZSH_TMUX_AUTOSTART" == "true" ]]; then
|
||||||
then
|
|
||||||
# Actually don't autostart if we already did and multiple autostarts are disabled.
|
# Actually don't autostart if we already did and multiple autostarts are disabled.
|
||||||
if [[ "$ZSH_TMUX_AUTOSTART_ONCE" == "false" || "$ZSH_TMUX_AUTOSTARTED" != "true" ]]
|
if [[ "$ZSH_TMUX_AUTOSTART_ONCE" == "false" || "$ZSH_TMUX_AUTOSTARTED" != "true" ]]; then
|
||||||
then
|
|
||||||
export ZSH_TMUX_AUTOSTARTED=true
|
export ZSH_TMUX_AUTOSTARTED=true
|
||||||
_zsh_tmux_plugin_run
|
_zsh_tmux_plugin_run
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
print "zsh tmux plugin: tmux not found. Please install tmux before using this plugin."
|
|
||||||
fi
|
|
||||||
|
Loading…
Reference in New Issue
Block a user