How to know what is the current tab - number or position - for any Window Terminal?

Hello Friends

For Ubuntu and Fedora if is opened a Window Terminal through ctrl + alt + t then is possible open a new tab through shift + ctrl + t. Suppose exists a Window Terminal with 5 tabs. If possible go to any of them through alt + # (where # can be 1-5) …

Now, if the Window Terminal has more tabs such as 9,10 …


  • How to know what is the current tab? Its number or position.

It to handle the following situations:

  • How to know to where return later (suppose that the current tab is 8, and we go to 3, and later is need it to return to 8). So is need it know/get 8.
  • What is the next/previous one of the current tab (suppose that the current tab is 7 and is need it go to the next tab, 8). So is need it know/get 7.

I tried the tty command, but if the current tab is 5, it shows /dev/pts/4. As you can see N-1. Until here can be applied a simple math … and some times shows the expected direct value, it such as /dev/pts/5. I don’t know why this difference. So the returned value is not always accurate.

Even more, if in other workspace exists other Window Terminal with some tabs, if is executed the tty command, appears a random number, it normally would be the continuation of the highest tab + 1 of the previous Window Terminal. So if in the first Window Terminal has 5 tabs in the second Window Terminal for its 1rst tab the tty command shows /dev/pts/5 (N-1) or directly /dev/pts/6. But is expected /dev/pts/1, so if new tabs are opened, the correlation should based starting from 1.

Observation consider if any tab is moved (drag and drop) to other position, the “command” should reflect the new position/number

Note Even if the tty would be not the correct command, what command would accomplish this goal?