If you also want the output, you can still use the
if set x (tmux ls | grep foo)
set doesn't set the status itself and simply passes on whatever the command substitution returned.
cmd 2>&1 >filedoesn’t redirect stderr to
cmd >file 2>&1does