From a GUI terminal emulator running bash, I would like to open a tabbed instance, get its X window ID, and use it to embed four st terminal instances inside tabbed, with titles from 1 to 4, in ascending or descending order. I tried the following script:


xid=`tabbed -cd`

while [ $i -le $1 ]; do
        st -t $i -w $xid &

It works, but the sts are launched not in the sequence imposed by the while cycle: the order of tabs, in fact, is random.

1) They must all be background processes, but how to obtain the correct order for them?

2) How to obtain the same with CLI?

$ xid=`tabbed -cd` && (st -t '1' -w $xid & st -t '2' -w $xid & st -t '3' -w $xid & st -t '4' -w $xid &)

creates an apparent random order like the script.

  • 1
    Probably the order of the tabs depends on how fast the st background programs come to the point where the tab is added. There is no guarantee that the one you ran first will be the first at this point. You could try a if [ $i -ne 1 ]; then sleep 1; fi before st -t $i -w $xid &. – Bodo Mar 4 at 12:40
  • @Bodo Thank you, I tried and it works correctly; just, it is very slow. IIUC, there is some random time between when the st process is launched and when it actually appears as a tab. Do you think there is not a way to verify if it has correctly beeen added as a tab, before running the next st? – BowPark Mar 4 at 19:27
  • To speed things up, I tried with sleep 0.25 (lower times cause again that random tab number order). But even 0.25 is too high, when several (4) tabs must be created. – BowPark Mar 4 at 19:29

Your Answer

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

Browse other questions tagged or ask your own question.