Bem, você poderia simplesmente emitir:
tty
Exemplo:
$ tty
/dev/pts/0
E se você somente quiser o número do terminal, tente:
$ tty | grep -o '.$'
0
De man tty :
NAME
tty - print the file name of the terminal connected to
standard input