How to change default new window directory from within the tmux












34















I recently moved from GNU screen to tmux.

I find it quite similar but with bigger support (I switched due to problem with escape-time in neovim- resolution was only for tmux).



Unfortunately in tmux I'm unable to find a similar command to this:



screen -X eval "chdir $(some_dir)"


The command above changed the default directory for new window/screen/pane from within the GNU screen so when I pressed Ctrl+a (similar to tmux Ctrl+b)- new window opened in the $(some_dir) directory.



Is there a similar thing in tmux?



ANSWER:

I have used @Lqueryvg answer and combined it with @Vincent Nivoliers suggestion froma a comment and that gave me a new binding for a command attach -c "#{pane_current_path}" which sets my current directory as a default one.

Thanks.










share|improve this question

























  • You could use the second answer of this question

    – Vincent Nivoliers
    Mar 8 '16 at 13:25













  • Thanks, it is helpful. new-window -c "#{pane_current_path}" is working but what I need is to set the path permanently, i.e.: I'm working in a project in /aaa/bbb but somehow I when I change path to say /ccc/ddd and start new with C-b and c I want to land one more time in /aaa/bbb. Can you think of a solution to this?

    – lewiatan
    Mar 8 '16 at 13:41











  • I am personally fine with the addition of the last three lines in my .tmux.conf. That way I only have to navigate once to the folder and then create my windows / split from there, but I admit this is not a solution to your problem, that's why I didn't post an answer !

    – Vincent Nivoliers
    Mar 8 '16 at 13:52


















34















I recently moved from GNU screen to tmux.

I find it quite similar but with bigger support (I switched due to problem with escape-time in neovim- resolution was only for tmux).



Unfortunately in tmux I'm unable to find a similar command to this:



screen -X eval "chdir $(some_dir)"


The command above changed the default directory for new window/screen/pane from within the GNU screen so when I pressed Ctrl+a (similar to tmux Ctrl+b)- new window opened in the $(some_dir) directory.



Is there a similar thing in tmux?



ANSWER:

I have used @Lqueryvg answer and combined it with @Vincent Nivoliers suggestion froma a comment and that gave me a new binding for a command attach -c "#{pane_current_path}" which sets my current directory as a default one.

Thanks.










share|improve this question

























  • You could use the second answer of this question

    – Vincent Nivoliers
    Mar 8 '16 at 13:25













  • Thanks, it is helpful. new-window -c "#{pane_current_path}" is working but what I need is to set the path permanently, i.e.: I'm working in a project in /aaa/bbb but somehow I when I change path to say /ccc/ddd and start new with C-b and c I want to land one more time in /aaa/bbb. Can you think of a solution to this?

    – lewiatan
    Mar 8 '16 at 13:41











  • I am personally fine with the addition of the last three lines in my .tmux.conf. That way I only have to navigate once to the folder and then create my windows / split from there, but I admit this is not a solution to your problem, that's why I didn't post an answer !

    – Vincent Nivoliers
    Mar 8 '16 at 13:52
















34












34








34


13






I recently moved from GNU screen to tmux.

I find it quite similar but with bigger support (I switched due to problem with escape-time in neovim- resolution was only for tmux).



Unfortunately in tmux I'm unable to find a similar command to this:



screen -X eval "chdir $(some_dir)"


The command above changed the default directory for new window/screen/pane from within the GNU screen so when I pressed Ctrl+a (similar to tmux Ctrl+b)- new window opened in the $(some_dir) directory.



Is there a similar thing in tmux?



ANSWER:

I have used @Lqueryvg answer and combined it with @Vincent Nivoliers suggestion froma a comment and that gave me a new binding for a command attach -c "#{pane_current_path}" which sets my current directory as a default one.

Thanks.










share|improve this question
















I recently moved from GNU screen to tmux.

I find it quite similar but with bigger support (I switched due to problem with escape-time in neovim- resolution was only for tmux).



Unfortunately in tmux I'm unable to find a similar command to this:



screen -X eval "chdir $(some_dir)"


The command above changed the default directory for new window/screen/pane from within the GNU screen so when I pressed Ctrl+a (similar to tmux Ctrl+b)- new window opened in the $(some_dir) directory.



Is there a similar thing in tmux?



ANSWER:

I have used @Lqueryvg answer and combined it with @Vincent Nivoliers suggestion froma a comment and that gave me a new binding for a command attach -c "#{pane_current_path}" which sets my current directory as a default one.

Thanks.







linux tmux gnu-screen






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 6 '16 at 7:59







lewiatan

















asked Mar 8 '16 at 13:09









lewiatanlewiatan

3691615




3691615













  • You could use the second answer of this question

    – Vincent Nivoliers
    Mar 8 '16 at 13:25













  • Thanks, it is helpful. new-window -c "#{pane_current_path}" is working but what I need is to set the path permanently, i.e.: I'm working in a project in /aaa/bbb but somehow I when I change path to say /ccc/ddd and start new with C-b and c I want to land one more time in /aaa/bbb. Can you think of a solution to this?

    – lewiatan
    Mar 8 '16 at 13:41











  • I am personally fine with the addition of the last three lines in my .tmux.conf. That way I only have to navigate once to the folder and then create my windows / split from there, but I admit this is not a solution to your problem, that's why I didn't post an answer !

    – Vincent Nivoliers
    Mar 8 '16 at 13:52





















  • You could use the second answer of this question

    – Vincent Nivoliers
    Mar 8 '16 at 13:25













  • Thanks, it is helpful. new-window -c "#{pane_current_path}" is working but what I need is to set the path permanently, i.e.: I'm working in a project in /aaa/bbb but somehow I when I change path to say /ccc/ddd and start new with C-b and c I want to land one more time in /aaa/bbb. Can you think of a solution to this?

    – lewiatan
    Mar 8 '16 at 13:41











  • I am personally fine with the addition of the last three lines in my .tmux.conf. That way I only have to navigate once to the folder and then create my windows / split from there, but I admit this is not a solution to your problem, that's why I didn't post an answer !

    – Vincent Nivoliers
    Mar 8 '16 at 13:52



















You could use the second answer of this question

– Vincent Nivoliers
Mar 8 '16 at 13:25







You could use the second answer of this question

– Vincent Nivoliers
Mar 8 '16 at 13:25















Thanks, it is helpful. new-window -c "#{pane_current_path}" is working but what I need is to set the path permanently, i.e.: I'm working in a project in /aaa/bbb but somehow I when I change path to say /ccc/ddd and start new with C-b and c I want to land one more time in /aaa/bbb. Can you think of a solution to this?

– lewiatan
Mar 8 '16 at 13:41





Thanks, it is helpful. new-window -c "#{pane_current_path}" is working but what I need is to set the path permanently, i.e.: I'm working in a project in /aaa/bbb but somehow I when I change path to say /ccc/ddd and start new with C-b and c I want to land one more time in /aaa/bbb. Can you think of a solution to this?

– lewiatan
Mar 8 '16 at 13:41













I am personally fine with the addition of the last three lines in my .tmux.conf. That way I only have to navigate once to the folder and then create my windows / split from there, but I admit this is not a solution to your problem, that's why I didn't post an answer !

– Vincent Nivoliers
Mar 8 '16 at 13:52







I am personally fine with the addition of the last three lines in my .tmux.conf. That way I only have to navigate once to the folder and then create my windows / split from there, but I admit this is not a solution to your problem, that's why I didn't post an answer !

– Vincent Nivoliers
Mar 8 '16 at 13:52












2 Answers
2






active

oldest

votes


















50
















  1. Start tmux as follows:



    (cd /aaa/bbb; tmux)


    Now, any new windows (or panes) you create will start in directory /aaa/bbb, regardless of the current directory of the current pane.




  2. If you want to change the default directory once tmux is up and running, use attach-session with -c.



    Quoting from the tmux man page for attach-session:



    -c will set the session working directory (used for new windows)
    to working-directory.


    For example:




    • Ctrl+b
      :


    • attach -c /ddd/eee



    New windows (or panes) will now start in directory /ddd/eee, regardless of the directory of the current pane.








share|improve this answer





















  • 6





    Second option is exactly what I wanted. I'm going to use attach -c "#{pane_current_path}" which would be the same as what I have had in screen. Thanks.

    – lewiatan
    Apr 6 '16 at 7:54











  • Yes! attach -c is exactly what I was looking for. Thank you

    – Byron Mansfield
    Aug 10 '18 at 1:37



















1














For those who might be looking for a bit more reference than the selected answer provides, there was a another good answer to this question over on StackOverflow:



https://stackoverflow.com/questions/27307815/how-to-change-the-starting-directory-of-a-tmux-session



Which provides ways you can do it without leaving the session, and for those who use tmux in a multi-session fashion (like myself), the above answer gives a bit better context as to how attach/attach-session works.



See both available answers for different ways they can be used. I found both to be helpful/insightful.






share|improve this answer








New contributor




nicklamuro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















    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',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    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%2f268386%2fhow-to-change-default-new-window-directory-from-within-the-tmux%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    50
















    1. Start tmux as follows:



      (cd /aaa/bbb; tmux)


      Now, any new windows (or panes) you create will start in directory /aaa/bbb, regardless of the current directory of the current pane.




    2. If you want to change the default directory once tmux is up and running, use attach-session with -c.



      Quoting from the tmux man page for attach-session:



      -c will set the session working directory (used for new windows)
      to working-directory.


      For example:




      • Ctrl+b
        :


      • attach -c /ddd/eee



      New windows (or panes) will now start in directory /ddd/eee, regardless of the directory of the current pane.








    share|improve this answer





















    • 6





      Second option is exactly what I wanted. I'm going to use attach -c "#{pane_current_path}" which would be the same as what I have had in screen. Thanks.

      – lewiatan
      Apr 6 '16 at 7:54











    • Yes! attach -c is exactly what I was looking for. Thank you

      – Byron Mansfield
      Aug 10 '18 at 1:37
















    50
















    1. Start tmux as follows:



      (cd /aaa/bbb; tmux)


      Now, any new windows (or panes) you create will start in directory /aaa/bbb, regardless of the current directory of the current pane.




    2. If you want to change the default directory once tmux is up and running, use attach-session with -c.



      Quoting from the tmux man page for attach-session:



      -c will set the session working directory (used for new windows)
      to working-directory.


      For example:




      • Ctrl+b
        :


      • attach -c /ddd/eee



      New windows (or panes) will now start in directory /ddd/eee, regardless of the directory of the current pane.








    share|improve this answer





















    • 6





      Second option is exactly what I wanted. I'm going to use attach -c "#{pane_current_path}" which would be the same as what I have had in screen. Thanks.

      – lewiatan
      Apr 6 '16 at 7:54











    • Yes! attach -c is exactly what I was looking for. Thank you

      – Byron Mansfield
      Aug 10 '18 at 1:37














    50












    50








    50









    1. Start tmux as follows:



      (cd /aaa/bbb; tmux)


      Now, any new windows (or panes) you create will start in directory /aaa/bbb, regardless of the current directory of the current pane.




    2. If you want to change the default directory once tmux is up and running, use attach-session with -c.



      Quoting from the tmux man page for attach-session:



      -c will set the session working directory (used for new windows)
      to working-directory.


      For example:




      • Ctrl+b
        :


      • attach -c /ddd/eee



      New windows (or panes) will now start in directory /ddd/eee, regardless of the directory of the current pane.








    share|improve this answer

















    1. Start tmux as follows:



      (cd /aaa/bbb; tmux)


      Now, any new windows (or panes) you create will start in directory /aaa/bbb, regardless of the current directory of the current pane.




    2. If you want to change the default directory once tmux is up and running, use attach-session with -c.



      Quoting from the tmux man page for attach-session:



      -c will set the session working directory (used for new windows)
      to working-directory.


      For example:




      • Ctrl+b
        :


      • attach -c /ddd/eee



      New windows (or panes) will now start in directory /ddd/eee, regardless of the directory of the current pane.









    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Apr 5 '16 at 22:19

























    answered Apr 5 '16 at 21:55









    LqueryvgLqueryvg

    909108




    909108








    • 6





      Second option is exactly what I wanted. I'm going to use attach -c "#{pane_current_path}" which would be the same as what I have had in screen. Thanks.

      – lewiatan
      Apr 6 '16 at 7:54











    • Yes! attach -c is exactly what I was looking for. Thank you

      – Byron Mansfield
      Aug 10 '18 at 1:37














    • 6





      Second option is exactly what I wanted. I'm going to use attach -c "#{pane_current_path}" which would be the same as what I have had in screen. Thanks.

      – lewiatan
      Apr 6 '16 at 7:54











    • Yes! attach -c is exactly what I was looking for. Thank you

      – Byron Mansfield
      Aug 10 '18 at 1:37








    6




    6





    Second option is exactly what I wanted. I'm going to use attach -c "#{pane_current_path}" which would be the same as what I have had in screen. Thanks.

    – lewiatan
    Apr 6 '16 at 7:54





    Second option is exactly what I wanted. I'm going to use attach -c "#{pane_current_path}" which would be the same as what I have had in screen. Thanks.

    – lewiatan
    Apr 6 '16 at 7:54













    Yes! attach -c is exactly what I was looking for. Thank you

    – Byron Mansfield
    Aug 10 '18 at 1:37





    Yes! attach -c is exactly what I was looking for. Thank you

    – Byron Mansfield
    Aug 10 '18 at 1:37













    1














    For those who might be looking for a bit more reference than the selected answer provides, there was a another good answer to this question over on StackOverflow:



    https://stackoverflow.com/questions/27307815/how-to-change-the-starting-directory-of-a-tmux-session



    Which provides ways you can do it without leaving the session, and for those who use tmux in a multi-session fashion (like myself), the above answer gives a bit better context as to how attach/attach-session works.



    See both available answers for different ways they can be used. I found both to be helpful/insightful.






    share|improve this answer








    New contributor




    nicklamuro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.

























      1














      For those who might be looking for a bit more reference than the selected answer provides, there was a another good answer to this question over on StackOverflow:



      https://stackoverflow.com/questions/27307815/how-to-change-the-starting-directory-of-a-tmux-session



      Which provides ways you can do it without leaving the session, and for those who use tmux in a multi-session fashion (like myself), the above answer gives a bit better context as to how attach/attach-session works.



      See both available answers for different ways they can be used. I found both to be helpful/insightful.






      share|improve this answer








      New contributor




      nicklamuro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.























        1












        1








        1







        For those who might be looking for a bit more reference than the selected answer provides, there was a another good answer to this question over on StackOverflow:



        https://stackoverflow.com/questions/27307815/how-to-change-the-starting-directory-of-a-tmux-session



        Which provides ways you can do it without leaving the session, and for those who use tmux in a multi-session fashion (like myself), the above answer gives a bit better context as to how attach/attach-session works.



        See both available answers for different ways they can be used. I found both to be helpful/insightful.






        share|improve this answer








        New contributor




        nicklamuro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.










        For those who might be looking for a bit more reference than the selected answer provides, there was a another good answer to this question over on StackOverflow:



        https://stackoverflow.com/questions/27307815/how-to-change-the-starting-directory-of-a-tmux-session



        Which provides ways you can do it without leaving the session, and for those who use tmux in a multi-session fashion (like myself), the above answer gives a bit better context as to how attach/attach-session works.



        See both available answers for different ways they can be used. I found both to be helpful/insightful.







        share|improve this answer








        New contributor




        nicklamuro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        nicklamuro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered 2 hours ago









        nicklamuronicklamuro

        111




        111




        New contributor




        nicklamuro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        nicklamuro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        nicklamuro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f268386%2fhow-to-change-default-new-window-directory-from-within-the-tmux%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Histoire des bourses de valeurs

            Why is there Russian traffic in my log files?

            Rename multiple files to decrement number in file name?