Switch between nested tmux sessions

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I'm writing a zsh script that setup nested session. I have a session and a session inside that session.



sessionA
sessionB


I can create sessionA in detach mode -d and then call tmux inside that to create nested sessionB but how to switch to sessionB?



I checked manpage and there's no switch-session option. Much appreciated.










share|improve this question

























    up vote
    0
    down vote

    favorite












    I'm writing a zsh script that setup nested session. I have a session and a session inside that session.



    sessionA
    sessionB


    I can create sessionA in detach mode -d and then call tmux inside that to create nested sessionB but how to switch to sessionB?



    I checked manpage and there's no switch-session option. Much appreciated.










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm writing a zsh script that setup nested session. I have a session and a session inside that session.



      sessionA
      sessionB


      I can create sessionA in detach mode -d and then call tmux inside that to create nested sessionB but how to switch to sessionB?



      I checked manpage and there's no switch-session option. Much appreciated.










      share|improve this question













      I'm writing a zsh script that setup nested session. I have a session and a session inside that session.



      sessionA
      sessionB


      I can create sessionA in detach mode -d and then call tmux inside that to create nested sessionB but how to switch to sessionB?



      I checked manpage and there's no switch-session option. Much appreciated.







      zsh tmux






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Sep 5 at 14:03









      Tuyen Pham

      19810




      19810




















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          1
          down vote













          You would first start a session:



          tmux new-session -s [session-name] -n [first-tmux-screen-name] -d


          We can now separate this window in sections by using splitw options:



          tmux splitw -h
          tmux splitw -v


          we can select a section too:



          tmux selectp -t0
          tmux splitw -v


          And depending on what we want to display, or run in each nested window, we use the send-key option. If we want to add a new window to this tmux session we can use this command:



          tmux new-window -n [name-of-new-window] -t [session-name]


          zsh works for me:



          #!/bin/zsh

          tmux new-session -s test -n four-screen -d
          tmux splitw -h
          tmux splitw -v
          tmux selectp -t0
          tmux splitw -v


          After your run the script: zsh scriptname.zsh then attach to the session: tmux attach






          share|improve this answer






















          • Why two -d in first session creation?
            – Tuyen Pham
            Sep 6 at 4:03










          • was suppose to be a -n sorry.
            – NiteRain
            Sep 6 at 4:04










          • Forgot to mention, after you do the last new-window, that is what you will see when you tmux attach -t [session], so to go to the first screen, you would have to do a tmux select-window -t [first-tmux-screen-name] in your script.
            – NiteRain
            Sep 6 at 4:08











          • I'm doing in zsh script so your answer probably won't help. Right now I have trouble to rename nested session. Output keep saying can't find session <NAME>
            – Tuyen Pham
            Sep 6 at 4:14











          • This is question about how to switch between nested session, your zsh script is about creating a new named session and window then spliting some panes - probably unrelated to the original question but thanks for the help.
            – Tuyen Pham
            Sep 6 at 4:48

















          up vote
          0
          down vote













          An easy solution is to detach and then attached directly to sessionB.



          tmux attach-session -t sessionB






          share|improve this answer




















          • In a script I'd need to switch to sessionB silently, so that the question.
            – Tuyen Pham
            Sep 6 at 2:08

















          up vote
          0
          down vote













          Seem like my question is a little bit not clear.



          Here I want to do tasks on nested session but after googling I can achieve that purpose via send-keys with option that specify session name to act on. So no need to switch to session that I'd need to work on - I'm in an zsh script perspective.






          share|improve this answer




















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f467025%2fswitch-between-nested-tmux-sessions%23new-answer', 'question_page');

            );

            Post as a guest






























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote













            You would first start a session:



            tmux new-session -s [session-name] -n [first-tmux-screen-name] -d


            We can now separate this window in sections by using splitw options:



            tmux splitw -h
            tmux splitw -v


            we can select a section too:



            tmux selectp -t0
            tmux splitw -v


            And depending on what we want to display, or run in each nested window, we use the send-key option. If we want to add a new window to this tmux session we can use this command:



            tmux new-window -n [name-of-new-window] -t [session-name]


            zsh works for me:



            #!/bin/zsh

            tmux new-session -s test -n four-screen -d
            tmux splitw -h
            tmux splitw -v
            tmux selectp -t0
            tmux splitw -v


            After your run the script: zsh scriptname.zsh then attach to the session: tmux attach






            share|improve this answer






















            • Why two -d in first session creation?
              – Tuyen Pham
              Sep 6 at 4:03










            • was suppose to be a -n sorry.
              – NiteRain
              Sep 6 at 4:04










            • Forgot to mention, after you do the last new-window, that is what you will see when you tmux attach -t [session], so to go to the first screen, you would have to do a tmux select-window -t [first-tmux-screen-name] in your script.
              – NiteRain
              Sep 6 at 4:08











            • I'm doing in zsh script so your answer probably won't help. Right now I have trouble to rename nested session. Output keep saying can't find session <NAME>
              – Tuyen Pham
              Sep 6 at 4:14











            • This is question about how to switch between nested session, your zsh script is about creating a new named session and window then spliting some panes - probably unrelated to the original question but thanks for the help.
              – Tuyen Pham
              Sep 6 at 4:48














            up vote
            1
            down vote













            You would first start a session:



            tmux new-session -s [session-name] -n [first-tmux-screen-name] -d


            We can now separate this window in sections by using splitw options:



            tmux splitw -h
            tmux splitw -v


            we can select a section too:



            tmux selectp -t0
            tmux splitw -v


            And depending on what we want to display, or run in each nested window, we use the send-key option. If we want to add a new window to this tmux session we can use this command:



            tmux new-window -n [name-of-new-window] -t [session-name]


            zsh works for me:



            #!/bin/zsh

            tmux new-session -s test -n four-screen -d
            tmux splitw -h
            tmux splitw -v
            tmux selectp -t0
            tmux splitw -v


            After your run the script: zsh scriptname.zsh then attach to the session: tmux attach






            share|improve this answer






















            • Why two -d in first session creation?
              – Tuyen Pham
              Sep 6 at 4:03










            • was suppose to be a -n sorry.
              – NiteRain
              Sep 6 at 4:04










            • Forgot to mention, after you do the last new-window, that is what you will see when you tmux attach -t [session], so to go to the first screen, you would have to do a tmux select-window -t [first-tmux-screen-name] in your script.
              – NiteRain
              Sep 6 at 4:08











            • I'm doing in zsh script so your answer probably won't help. Right now I have trouble to rename nested session. Output keep saying can't find session <NAME>
              – Tuyen Pham
              Sep 6 at 4:14











            • This is question about how to switch between nested session, your zsh script is about creating a new named session and window then spliting some panes - probably unrelated to the original question but thanks for the help.
              – Tuyen Pham
              Sep 6 at 4:48












            up vote
            1
            down vote










            up vote
            1
            down vote









            You would first start a session:



            tmux new-session -s [session-name] -n [first-tmux-screen-name] -d


            We can now separate this window in sections by using splitw options:



            tmux splitw -h
            tmux splitw -v


            we can select a section too:



            tmux selectp -t0
            tmux splitw -v


            And depending on what we want to display, or run in each nested window, we use the send-key option. If we want to add a new window to this tmux session we can use this command:



            tmux new-window -n [name-of-new-window] -t [session-name]


            zsh works for me:



            #!/bin/zsh

            tmux new-session -s test -n four-screen -d
            tmux splitw -h
            tmux splitw -v
            tmux selectp -t0
            tmux splitw -v


            After your run the script: zsh scriptname.zsh then attach to the session: tmux attach






            share|improve this answer














            You would first start a session:



            tmux new-session -s [session-name] -n [first-tmux-screen-name] -d


            We can now separate this window in sections by using splitw options:



            tmux splitw -h
            tmux splitw -v


            we can select a section too:



            tmux selectp -t0
            tmux splitw -v


            And depending on what we want to display, or run in each nested window, we use the send-key option. If we want to add a new window to this tmux session we can use this command:



            tmux new-window -n [name-of-new-window] -t [session-name]


            zsh works for me:



            #!/bin/zsh

            tmux new-session -s test -n four-screen -d
            tmux splitw -h
            tmux splitw -v
            tmux selectp -t0
            tmux splitw -v


            After your run the script: zsh scriptname.zsh then attach to the session: tmux attach







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Sep 6 at 4:23

























            answered Sep 6 at 4:00









            NiteRain

            1104




            1104











            • Why two -d in first session creation?
              – Tuyen Pham
              Sep 6 at 4:03










            • was suppose to be a -n sorry.
              – NiteRain
              Sep 6 at 4:04










            • Forgot to mention, after you do the last new-window, that is what you will see when you tmux attach -t [session], so to go to the first screen, you would have to do a tmux select-window -t [first-tmux-screen-name] in your script.
              – NiteRain
              Sep 6 at 4:08











            • I'm doing in zsh script so your answer probably won't help. Right now I have trouble to rename nested session. Output keep saying can't find session <NAME>
              – Tuyen Pham
              Sep 6 at 4:14











            • This is question about how to switch between nested session, your zsh script is about creating a new named session and window then spliting some panes - probably unrelated to the original question but thanks for the help.
              – Tuyen Pham
              Sep 6 at 4:48
















            • Why two -d in first session creation?
              – Tuyen Pham
              Sep 6 at 4:03










            • was suppose to be a -n sorry.
              – NiteRain
              Sep 6 at 4:04










            • Forgot to mention, after you do the last new-window, that is what you will see when you tmux attach -t [session], so to go to the first screen, you would have to do a tmux select-window -t [first-tmux-screen-name] in your script.
              – NiteRain
              Sep 6 at 4:08











            • I'm doing in zsh script so your answer probably won't help. Right now I have trouble to rename nested session. Output keep saying can't find session <NAME>
              – Tuyen Pham
              Sep 6 at 4:14











            • This is question about how to switch between nested session, your zsh script is about creating a new named session and window then spliting some panes - probably unrelated to the original question but thanks for the help.
              – Tuyen Pham
              Sep 6 at 4:48















            Why two -d in first session creation?
            – Tuyen Pham
            Sep 6 at 4:03




            Why two -d in first session creation?
            – Tuyen Pham
            Sep 6 at 4:03












            was suppose to be a -n sorry.
            – NiteRain
            Sep 6 at 4:04




            was suppose to be a -n sorry.
            – NiteRain
            Sep 6 at 4:04












            Forgot to mention, after you do the last new-window, that is what you will see when you tmux attach -t [session], so to go to the first screen, you would have to do a tmux select-window -t [first-tmux-screen-name] in your script.
            – NiteRain
            Sep 6 at 4:08





            Forgot to mention, after you do the last new-window, that is what you will see when you tmux attach -t [session], so to go to the first screen, you would have to do a tmux select-window -t [first-tmux-screen-name] in your script.
            – NiteRain
            Sep 6 at 4:08













            I'm doing in zsh script so your answer probably won't help. Right now I have trouble to rename nested session. Output keep saying can't find session <NAME>
            – Tuyen Pham
            Sep 6 at 4:14





            I'm doing in zsh script so your answer probably won't help. Right now I have trouble to rename nested session. Output keep saying can't find session <NAME>
            – Tuyen Pham
            Sep 6 at 4:14













            This is question about how to switch between nested session, your zsh script is about creating a new named session and window then spliting some panes - probably unrelated to the original question but thanks for the help.
            – Tuyen Pham
            Sep 6 at 4:48




            This is question about how to switch between nested session, your zsh script is about creating a new named session and window then spliting some panes - probably unrelated to the original question but thanks for the help.
            – Tuyen Pham
            Sep 6 at 4:48












            up vote
            0
            down vote













            An easy solution is to detach and then attached directly to sessionB.



            tmux attach-session -t sessionB






            share|improve this answer




















            • In a script I'd need to switch to sessionB silently, so that the question.
              – Tuyen Pham
              Sep 6 at 2:08














            up vote
            0
            down vote













            An easy solution is to detach and then attached directly to sessionB.



            tmux attach-session -t sessionB






            share|improve this answer




















            • In a script I'd need to switch to sessionB silently, so that the question.
              – Tuyen Pham
              Sep 6 at 2:08












            up vote
            0
            down vote










            up vote
            0
            down vote









            An easy solution is to detach and then attached directly to sessionB.



            tmux attach-session -t sessionB






            share|improve this answer












            An easy solution is to detach and then attached directly to sessionB.



            tmux attach-session -t sessionB







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Sep 5 at 14:19









            foobaru

            843




            843











            • In a script I'd need to switch to sessionB silently, so that the question.
              – Tuyen Pham
              Sep 6 at 2:08
















            • In a script I'd need to switch to sessionB silently, so that the question.
              – Tuyen Pham
              Sep 6 at 2:08















            In a script I'd need to switch to sessionB silently, so that the question.
            – Tuyen Pham
            Sep 6 at 2:08




            In a script I'd need to switch to sessionB silently, so that the question.
            – Tuyen Pham
            Sep 6 at 2:08










            up vote
            0
            down vote













            Seem like my question is a little bit not clear.



            Here I want to do tasks on nested session but after googling I can achieve that purpose via send-keys with option that specify session name to act on. So no need to switch to session that I'd need to work on - I'm in an zsh script perspective.






            share|improve this answer
























              up vote
              0
              down vote













              Seem like my question is a little bit not clear.



              Here I want to do tasks on nested session but after googling I can achieve that purpose via send-keys with option that specify session name to act on. So no need to switch to session that I'd need to work on - I'm in an zsh script perspective.






              share|improve this answer






















                up vote
                0
                down vote










                up vote
                0
                down vote









                Seem like my question is a little bit not clear.



                Here I want to do tasks on nested session but after googling I can achieve that purpose via send-keys with option that specify session name to act on. So no need to switch to session that I'd need to work on - I'm in an zsh script perspective.






                share|improve this answer












                Seem like my question is a little bit not clear.



                Here I want to do tasks on nested session but after googling I can achieve that purpose via send-keys with option that specify session name to act on. So no need to switch to session that I'd need to work on - I'm in an zsh script perspective.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Sep 6 at 3:15









                Tuyen Pham

                19810




                19810



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f467025%2fswitch-between-nested-tmux-sessions%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Displaying single band from multi-band raster using QGIS

                    How many registers does an x86_64 CPU actually have?