How to split the window that ran the “tmux split-window” command instead of the current one?

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











up vote
0
down vote

favorite












For example, if I run from window 0:



sleep 2;tmux split-window -h 


and switch to another window 1 with prefix-n before the sleep is over, the window split happens on the new window 1.



How to make the split always happen on window 0 when the command is run from window 0, regardless of the current window?



I have found this possibility:



win="$(tmux display-message -p '#I')";sleep 2;tmux split-window -h -t "$win"


based on: https://superuser.com/questions/385472/get-current-window-number-for-bash-prompt but I don't like it forces me to run an extra command before sleep 2 (which is a real useful command that takes a long time to finish in my use case), which is cumbersome.



Tested on tmux 2.5.



https://groups.google.com/forum/#!topic/tmux-users/ZtEuCZQS_lI







share|improve this question

























    up vote
    0
    down vote

    favorite












    For example, if I run from window 0:



    sleep 2;tmux split-window -h 


    and switch to another window 1 with prefix-n before the sleep is over, the window split happens on the new window 1.



    How to make the split always happen on window 0 when the command is run from window 0, regardless of the current window?



    I have found this possibility:



    win="$(tmux display-message -p '#I')";sleep 2;tmux split-window -h -t "$win"


    based on: https://superuser.com/questions/385472/get-current-window-number-for-bash-prompt but I don't like it forces me to run an extra command before sleep 2 (which is a real useful command that takes a long time to finish in my use case), which is cumbersome.



    Tested on tmux 2.5.



    https://groups.google.com/forum/#!topic/tmux-users/ZtEuCZQS_lI







    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      For example, if I run from window 0:



      sleep 2;tmux split-window -h 


      and switch to another window 1 with prefix-n before the sleep is over, the window split happens on the new window 1.



      How to make the split always happen on window 0 when the command is run from window 0, regardless of the current window?



      I have found this possibility:



      win="$(tmux display-message -p '#I')";sleep 2;tmux split-window -h -t "$win"


      based on: https://superuser.com/questions/385472/get-current-window-number-for-bash-prompt but I don't like it forces me to run an extra command before sleep 2 (which is a real useful command that takes a long time to finish in my use case), which is cumbersome.



      Tested on tmux 2.5.



      https://groups.google.com/forum/#!topic/tmux-users/ZtEuCZQS_lI







      share|improve this question













      For example, if I run from window 0:



      sleep 2;tmux split-window -h 


      and switch to another window 1 with prefix-n before the sleep is over, the window split happens on the new window 1.



      How to make the split always happen on window 0 when the command is run from window 0, regardless of the current window?



      I have found this possibility:



      win="$(tmux display-message -p '#I')";sleep 2;tmux split-window -h -t "$win"


      based on: https://superuser.com/questions/385472/get-current-window-number-for-bash-prompt but I don't like it forces me to run an extra command before sleep 2 (which is a real useful command that takes a long time to finish in my use case), which is cumbersome.



      Tested on tmux 2.5.



      https://groups.google.com/forum/#!topic/tmux-users/ZtEuCZQS_lI









      share|improve this question












      share|improve this question




      share|improve this question








      edited Apr 22 at 20:13
























      asked Apr 20 at 21:55









      Ciro Santilli 新疆改造中心 六四事件 法轮功

      4,04613533




      4,04613533




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          $TMUX_PANE



          tmux automatically defines this variable for us, and it just works:



          sleep 2;tmux split-window -h -t $TMUX_PANE


          This gives focus to the split when it gets created, this can be prevented with -d:



          sleep 2;tmux split-window -dh -t $TMUX_PANE





          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%2f439031%2fhow-to-split-the-window-that-ran-the-tmux-split-window-command-instead-of-the%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            $TMUX_PANE



            tmux automatically defines this variable for us, and it just works:



            sleep 2;tmux split-window -h -t $TMUX_PANE


            This gives focus to the split when it gets created, this can be prevented with -d:



            sleep 2;tmux split-window -dh -t $TMUX_PANE





            share|improve this answer



























              up vote
              0
              down vote













              $TMUX_PANE



              tmux automatically defines this variable for us, and it just works:



              sleep 2;tmux split-window -h -t $TMUX_PANE


              This gives focus to the split when it gets created, this can be prevented with -d:



              sleep 2;tmux split-window -dh -t $TMUX_PANE





              share|improve this answer

























                up vote
                0
                down vote










                up vote
                0
                down vote









                $TMUX_PANE



                tmux automatically defines this variable for us, and it just works:



                sleep 2;tmux split-window -h -t $TMUX_PANE


                This gives focus to the split when it gets created, this can be prevented with -d:



                sleep 2;tmux split-window -dh -t $TMUX_PANE





                share|improve this answer















                $TMUX_PANE



                tmux automatically defines this variable for us, and it just works:



                sleep 2;tmux split-window -h -t $TMUX_PANE


                This gives focus to the split when it gets created, this can be prevented with -d:



                sleep 2;tmux split-window -dh -t $TMUX_PANE






                share|improve this answer















                share|improve this answer



                share|improve this answer








                edited Apr 22 at 21:12


























                answered Apr 20 at 21:55









                Ciro Santilli 新疆改造中心 六四事件 法轮功

                4,04613533




                4,04613533






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f439031%2fhow-to-split-the-window-that-ran-the-tmux-split-window-command-instead-of-the%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    Peggy Mitchell

                    Palaiologos

                    The Forum (Inglewood, California)