Is there a way to switch to the last terminal tab with some commands or bash script?
What I have got so far:
To switch to the next tab:
xdotool key ctrl+Page_DownTo get the number of terminal tabs:
let terminal_counts=$(ls /dev/pts/ | wc -l)-1
Now I need to know how many times I need to execute xdotool key ctrl+Page_Down. How to know the current tab number?

Ctrl+PageUptakes you to the previous terminal tab (but not the last terminal tab). – WinEunuuchs2Unix Oct 03 '19 at 03:32