Ubuntu – Command to switch to the last terminal tab

bashcommand linegnome-terminal

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?

Best Answer

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

Hi