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_Down
  • To 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?

  • You didn't mention it but Ctrl+PageUp takes you to the previous terminal tab (but not the last terminal tab). Oct 3 '19 at 3:32

In gnome-terminal.. there is inbuilt function without assigning any shortcut key..

you can assign a shortcut key by Selecting Edit -- >> Preferences -- >> Shortcuts -->> Switch to Last Tab and by pressing valid key/ key combination like below


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.