-Fix: get id and tty in a function; more robust tmux session and tty detection