Generalize terminal window matching