Copy of IsTerminal from ssh/terminal.