Add tmux detection, improve xterm detection