My .bashrc file on my server is relatively simple, but it has this chunk to ensure that it automatically connects to tmux on login:
echo Checking for tmux
if [ -z ${TMUX} ]
then
/usr/bin/tmux attach || /usr/bin/tmux
fi
This generally works fine, but when I try to scp to this server it doesn't work. I see the "Checking for tmux" message on my local terminal when I scp followed by "no sessions; not a terminal". To fix this I tried changing the test above to
if [ -z ${TMUX} ] && [ -t 0 ]
This gets rid of the "no sessions; not a terminal" error, but the files just silently don't copy. The copy works fine if I comment out the above entirely, so clearly the problem is with this, but I'm not sure why it would be affecting anything if it just fails the above test. What is happening?