0
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-09-19 04:01:21 +02:00

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:
Andrew Janke 2015-09-27 22:06:58 -04:00 committed by Marc Cornellà
parent 106f826075
commit f33691fbb6

View file

@ -10,8 +10,11 @@ alias tksv='tmux kill-server'
alias tkss='tmux kill-session -t'
# Only run if tmux is actually installed
if which tmux &> /dev/null
then
if ! which tmux &> /dev/null; then
print "zsh tmux plugin: tmux not found. Please install tmux before using this plugin."
return 1
fi
# Configuration variables
#
# Automatically start tmux
@ -41,16 +44,14 @@ if which tmux &> /dev/null
local zsh_tmux_plugin_path="$(cd "$(dirname "$0")" && pwd)"
# Determine if the terminal supports 256 colors
if [[ `tput colors` == "256" ]]
then
if [[ `tput colors` == "256" ]]; then
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR
else
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITHOUT_256COLOR
fi
# Set the correct local config file to use.
if [[ "$ZSH_TMUX_ITERM2" == "false" ]] && [[ -f $HOME/.tmux.conf || -h $HOME/.tmux.conf ]]
then
if [[ "$ZSH_TMUX_ITERM2" == "false" ]] && [[ -f $HOME/.tmux.conf || -h $HOME/.tmux.conf ]]; then
#use this when they have a ~/.tmux.conf
export _ZSH_TMUX_FIXED_CONFIG="$zsh_tmux_plugin_path/tmux.extra.conf"
else
@ -59,15 +60,12 @@ if which tmux &> /dev/null
fi
# Wrapper function for tmux.
function _zsh_tmux_plugin_run()
{
function _zsh_tmux_plugin_run() {
# We have other arguments, just run them
if [[ -n "$@" ]]
then
if [[ -n "$@" ]]; then
\tmux $@
# Try to connect to an existing session.
elif [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]]
then
elif [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]]; 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
[[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] && exit
# Just run tmux, fixing the TERM variable if requested.
@ -84,15 +82,10 @@ if which tmux &> /dev/null
alias tmux=_zsh_tmux_plugin_run
# Autostart if not already in tmux and enabled.
if [[ ! -n "$TMUX" && "$ZSH_TMUX_AUTOSTART" == "true" ]]
then
if [[ ! -n "$TMUX" && "$ZSH_TMUX_AUTOSTART" == "true" ]]; then
# Actually don't autostart if we already did and multiple autostarts are disabled.
if [[ "$ZSH_TMUX_AUTOSTART_ONCE" == "false" || "$ZSH_TMUX_AUTOSTARTED" != "true" ]]
then
if [[ "$ZSH_TMUX_AUTOSTART_ONCE" == "false" || "$ZSH_TMUX_AUTOSTARTED" != "true" ]]; then
export ZSH_TMUX_AUTOSTARTED=true
_zsh_tmux_plugin_run
fi
fi
else
print "zsh tmux plugin: tmux not found. Please install tmux before using this plugin."
fi