I'm working on a bash function to check if a tmux session is running. The function works but if no session is running it outputs "failed to connect to server". How do I output that error to null without appending 1>&2 to every function call?
tmux_checker()
{
if [ -z $(tmux ls | grep -o servercontrol) ]
then
tmux new -d -s servercontrol
fi
}
tmux_checker #> /dev/null 2>&1 or 1>&2
tmux_checkermultiple times in the script and didn't want to have to call it astmux_checker 2>&/dev/nulleach time.