I use tmux on most boxes, but not all.
I have the following line in my .bashrc file:
[ -z "$TMUX" ] && export TERM=xterm-256color && exec tmux
which invoke tmux if it exists.
I thought the [ -z $TMUX ] meant that it would only be used if tmux exists.
However on another system, without tmux, I get
-bash: exec: tmux: not found
and the login attempt fails
On my main system I see
$ echo $TMUX
/private/var/folders/ks/266xy5lj7x35gfj4csc66444b48rvq/T/tmux-373580663/default,55084,4
I also tried just [ $TMUX ] (i.e. no -z) but that didn't help
I'm also looking for a robust solution that works in Ubuntu as well as OSX
which tmux &>/dev/null && .... Capturing the output and testing if empty is just dirty :-) – phemmer Jul 23 '14 at 14:40TERM=xterm-256color exec tmux:-) – phemmer Jul 23 '14 at 14:46.bashrc, then you are correct, it's a problem. A complete solution would involve a combination of checking to see if$TMUXis empty, and if the executable is present. – phemmer Jul 23 '14 at 14:48which. – Gilles 'SO- stop being evil' Jul 23 '14 at 23:06whichas it was about not capturing the output (see original version of the answer). Yes,command -vis safer, but I wasn't addressing that bit :-) – phemmer Jul 23 '14 at 23:10