f0a920df5a4a5e5260ef45daf27d42a15cd75217

Author
Josh Matthews <jmatth@nbcs.rutgers.edu>
Committer
Josh Matthews <jmatth@nbcs.rutgers.edu>
Date

Message

Checking to make sure tmux is actually installed before running plugin.

If it is not found an error message is printed.

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh
  2index be92fe096a8e76fba9cf43ff7e455e6b2b783856..6f0d5902ad0cf6764703e6c1d3b9fecd41c0ed70 100644
  3--- a/plugins/tmux/tmux.plugin.zsh
  4+++ b/plugins/tmux/tmux.plugin.zsh
  5@@ -1,82 +1,88 @@
  6-# Configuration variables
  7-#
  8-# Automatically start tmux
  9-[[ -n "$ZSH_TMUX_AUTOSTART" ]] || ZSH_TMUX_AUTOSTART=false
 10-# Only autostart once. If set to false, tmux will attempt to
 11-# autostart every time your zsh configs are reloaded.
 12-[[ -n "$ZSH_TMUX_AUTOSTART_ONCE" ]] || ZSH_TMUX_AUTOSTART_ONCE=true
 13-# Automatically connect to a previous session if it exists
 14-[[ -n "$ZSH_TMUX_AUTOCONNECT" ]] || ZSH_TMUX_AUTOCONNECT=true
 15-# Automatically close the terminal when tmux exits
 16-[[ -n "$ZSH_TMUX_AUTOQUIT" ]] || ZSH_TMUX_AUTOQUIT=$ZSH_TMUX_AUTOSTART
 17-# Set term to screen or screen-256color based on current terminal support
 18-[[ -n "$ZSH_TMUX_FIXTERM" ]] || ZSH_TMUX_FIXTERM=true
 19-# The TERM to use for non-256 color terminals.
 20-# Tmux states this should be screen, but you may need to change it on
 21-# systems without the proper terminfo
 22-[[ -n "$ZSH_TMUX_FIXTERM_WITHOUT_256COLOR" ]] || ZSH_TMUX_FIXTERM_WITHOUT_256COLOR="screen"
 23-# The TERM to use for 256 color terminals.
 24-# Tmux states this should be screen-256color, but you may need to change it on
 25-# systems without the proper terminfo
 26-[[ -n "$ZSH_TMUX_FIXTERM_WITH_256COLOR" ]] || ZSH_TMUX_FIXTERM_WITH_256COLOR="screen-256color"
 27-
 28+# Only run if tmux is actually installed
 29+if which tmux &> /dev/null
 30+	then
 31+	# Configuration variables
 32+	#
 33+	# Automatically start tmux
 34+	[[ -n "$ZSH_TMUX_AUTOSTART" ]] || ZSH_TMUX_AUTOSTART=false
 35+	# Only autostart once. If set to false, tmux will attempt to
 36+	# autostart every time your zsh configs are reloaded.
 37+	[[ -n "$ZSH_TMUX_AUTOSTART_ONCE" ]] || ZSH_TMUX_AUTOSTART_ONCE=true
 38+	# Automatically connect to a previous session if it exists
 39+	[[ -n "$ZSH_TMUX_AUTOCONNECT" ]] || ZSH_TMUX_AUTOCONNECT=true
 40+	# Automatically close the terminal when tmux exits
 41+	[[ -n "$ZSH_TMUX_AUTOQUIT" ]] || ZSH_TMUX_AUTOQUIT=$ZSH_TMUX_AUTOSTART
 42+	# Set term to screen or screen-256color based on current terminal support
 43+	[[ -n "$ZSH_TMUX_FIXTERM" ]] || ZSH_TMUX_FIXTERM=true
 44+	# The TERM to use for non-256 color terminals.
 45+	# Tmux states this should be screen, but you may need to change it on
 46+	# systems without the proper terminfo
 47+	[[ -n "$ZSH_TMUX_FIXTERM_WITHOUT_256COLOR" ]] || ZSH_TMUX_FIXTERM_WITHOUT_256COLOR="screen"
 48+	# The TERM to use for 256 color terminals.
 49+	# Tmux states this should be screen-256color, but you may need to change it on
 50+	# systems without the proper terminfo
 51+	[[ -n "$ZSH_TMUX_FIXTERM_WITH_256COLOR" ]] || ZSH_TMUX_FIXTERM_WITH_256COLOR="screen-256color"
 52 
 53-# Get the absolute path to the current directory
 54-local zsh_tmux_plugin_path="$(cd "$(dirname "$0")" && pwd)"
 55 
 56-# Determine if the terminal supports 256 colors
 57-if [[ `tput colors` == "256" ]]
 58-then
 59-	export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR
 60-else
 61-	export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITHOUT_256COLOR
 62-fi
 63+	# Get the absolute path to the current directory
 64+	local zsh_tmux_plugin_path="$(cd "$(dirname "$0")" && pwd)"
 65 
 66-# Local variable to store the local config file to use, if any.
 67-local fixed_config=""
 68+	# Determine if the terminal supports 256 colors
 69+	if [[ `tput colors` == "256" ]]
 70+	then
 71+		export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR
 72+	else
 73+		export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITHOUT_256COLOR
 74+	fi
 75 
 76-# Set the correct local config file to use.
 77-if [[ -f $HOME/.tmux.conf || -h $HOME/.tmux.conf ]]
 78-then
 79-	#use this when they have a ~/.tmux.conf
 80-	fixed_config="$zsh_tmux_plugin_path/tmux.extra.conf"
 81-else
 82-	#use this when they don't have a ~/.tmux.conf
 83-	fixed_config="$zsh_tmux_plugin_path/tmux.only.conf"
 84-fi
 85+	# Local variable to store the local config file to use, if any.
 86+	local fixed_config=""
 87 
 88-# Wrapper function for tmux.
 89-function zsh_tmux_plugin_run()
 90-{
 91-	# We have other arguments, just run them
 92-	if [[ -n "$@" ]]
 93+	# Set the correct local config file to use.
 94+	if [[ -f $HOME/.tmux.conf || -h $HOME/.tmux.conf ]]
 95 	then
 96-		\tmux $@
 97-	# Try to connect to an existing session.
 98-	elif [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]]
 99-	then
100-		\tmux attach || \tmux `[[ "$ZSH_TMUX_FIXTERM" == "true" ]] && echo '-f '$fixed_config`  new-session
101-		[[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] && exit
102-	# Just run tmux, fixing the TERM variable if requested.
103+		#use this when they have a ~/.tmux.conf
104+		fixed_config="$zsh_tmux_plugin_path/tmux.extra.conf"