Running a subshell from the middle of the current command












6















I frequently find my self in this scenario. I'm in the middle of typing a command and I need to check something else before I complete it.



Is there a way to open a subshell of some sort with my current input so far being remembered, then when I exit this subshell I'm back to where I was?



$ mylongcommand -n -e <SOME KEY COMBINATION WHICH OPENS A SUBSHELL>
$ date
...
$ exit
$ mylongcommand -n -e <BACK TO WHERE I WAS>


I'm using zsh










share|improve this question























  • Why not just open another terminal window?

    – Barmar
    1 hour ago
















6















I frequently find my self in this scenario. I'm in the middle of typing a command and I need to check something else before I complete it.



Is there a way to open a subshell of some sort with my current input so far being remembered, then when I exit this subshell I'm back to where I was?



$ mylongcommand -n -e <SOME KEY COMBINATION WHICH OPENS A SUBSHELL>
$ date
...
$ exit
$ mylongcommand -n -e <BACK TO WHERE I WAS>


I'm using zsh










share|improve this question























  • Why not just open another terminal window?

    – Barmar
    1 hour ago














6












6








6








I frequently find my self in this scenario. I'm in the middle of typing a command and I need to check something else before I complete it.



Is there a way to open a subshell of some sort with my current input so far being remembered, then when I exit this subshell I'm back to where I was?



$ mylongcommand -n -e <SOME KEY COMBINATION WHICH OPENS A SUBSHELL>
$ date
...
$ exit
$ mylongcommand -n -e <BACK TO WHERE I WAS>


I'm using zsh










share|improve this question














I frequently find my self in this scenario. I'm in the middle of typing a command and I need to check something else before I complete it.



Is there a way to open a subshell of some sort with my current input so far being remembered, then when I exit this subshell I'm back to where I was?



$ mylongcommand -n -e <SOME KEY COMBINATION WHICH OPENS A SUBSHELL>
$ date
...
$ exit
$ mylongcommand -n -e <BACK TO WHERE I WAS>


I'm using zsh







zsh






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 6 hours ago









PanayiotisPanayiotis

1503




1503













  • Why not just open another terminal window?

    – Barmar
    1 hour ago



















  • Why not just open another terminal window?

    – Barmar
    1 hour ago

















Why not just open another terminal window?

– Barmar
1 hour ago





Why not just open another terminal window?

– Barmar
1 hour ago










2 Answers
2






active

oldest

votes


















9














There is the key combination EscQ which saves the command buffer and allows to enter a new command. After running the command the buffer contains what you typed before. If you have to run another command before finishing this you can type EscQ again.



(I didn't try to open a subshell after pressing EscQ yet.)



See http://zsh.sourceforge.net/Intro/intro_10.html and search for "esc-q"






share|improve this answer
























  • This exactly what I wanted, thanks a lot! I could make it run a nested shell instead of returning straight away but for my use case returning straight away works perfectly.

    – Panayiotis
    5 hours ago



















7














I typically use Ctrl+U which erases the current line and saves it into a buffer. From there I do what ever it was I needed to before the mylongcommand. Then when I am ready I use Ctrl+Y to paste mylongcommand back in my prompt.



Remember a half-typed command while I check something






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',
    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%2f506070%2frunning-a-subshell-from-the-middle-of-the-current-command%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









    9














    There is the key combination EscQ which saves the command buffer and allows to enter a new command. After running the command the buffer contains what you typed before. If you have to run another command before finishing this you can type EscQ again.



    (I didn't try to open a subshell after pressing EscQ yet.)



    See http://zsh.sourceforge.net/Intro/intro_10.html and search for "esc-q"






    share|improve this answer
























    • This exactly what I wanted, thanks a lot! I could make it run a nested shell instead of returning straight away but for my use case returning straight away works perfectly.

      – Panayiotis
      5 hours ago
















    9














    There is the key combination EscQ which saves the command buffer and allows to enter a new command. After running the command the buffer contains what you typed before. If you have to run another command before finishing this you can type EscQ again.



    (I didn't try to open a subshell after pressing EscQ yet.)



    See http://zsh.sourceforge.net/Intro/intro_10.html and search for "esc-q"






    share|improve this answer
























    • This exactly what I wanted, thanks a lot! I could make it run a nested shell instead of returning straight away but for my use case returning straight away works perfectly.

      – Panayiotis
      5 hours ago














    9












    9








    9







    There is the key combination EscQ which saves the command buffer and allows to enter a new command. After running the command the buffer contains what you typed before. If you have to run another command before finishing this you can type EscQ again.



    (I didn't try to open a subshell after pressing EscQ yet.)



    See http://zsh.sourceforge.net/Intro/intro_10.html and search for "esc-q"






    share|improve this answer













    There is the key combination EscQ which saves the command buffer and allows to enter a new command. After running the command the buffer contains what you typed before. If you have to run another command before finishing this you can type EscQ again.



    (I didn't try to open a subshell after pressing EscQ yet.)



    See http://zsh.sourceforge.net/Intro/intro_10.html and search for "esc-q"







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered 5 hours ago









    BodoBodo

    2,181417




    2,181417













    • This exactly what I wanted, thanks a lot! I could make it run a nested shell instead of returning straight away but for my use case returning straight away works perfectly.

      – Panayiotis
      5 hours ago



















    • This exactly what I wanted, thanks a lot! I could make it run a nested shell instead of returning straight away but for my use case returning straight away works perfectly.

      – Panayiotis
      5 hours ago

















    This exactly what I wanted, thanks a lot! I could make it run a nested shell instead of returning straight away but for my use case returning straight away works perfectly.

    – Panayiotis
    5 hours ago





    This exactly what I wanted, thanks a lot! I could make it run a nested shell instead of returning straight away but for my use case returning straight away works perfectly.

    – Panayiotis
    5 hours ago













    7














    I typically use Ctrl+U which erases the current line and saves it into a buffer. From there I do what ever it was I needed to before the mylongcommand. Then when I am ready I use Ctrl+Y to paste mylongcommand back in my prompt.



    Remember a half-typed command while I check something






    share|improve this answer




























      7














      I typically use Ctrl+U which erases the current line and saves it into a buffer. From there I do what ever it was I needed to before the mylongcommand. Then when I am ready I use Ctrl+Y to paste mylongcommand back in my prompt.



      Remember a half-typed command while I check something






      share|improve this answer


























        7












        7








        7







        I typically use Ctrl+U which erases the current line and saves it into a buffer. From there I do what ever it was I needed to before the mylongcommand. Then when I am ready I use Ctrl+Y to paste mylongcommand back in my prompt.



        Remember a half-typed command while I check something






        share|improve this answer













        I typically use Ctrl+U which erases the current line and saves it into a buffer. From there I do what ever it was I needed to before the mylongcommand. Then when I am ready I use Ctrl+Y to paste mylongcommand back in my prompt.



        Remember a half-typed command while I check something







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 5 hours ago









        Zachary BradyZachary Brady

        3,4861033




        3,4861033






























            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%2f506070%2frunning-a-subshell-from-the-middle-of-the-current-command%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

            Callistus I

            Tabula Rosettana

            How to label and detect the document text images