Copying blocks of text in terminal











up vote
22
down vote

favorite
3












Is it possible to copy a "block" of text from a terminal window without having to copy entire lines?



Example:



enter image description here



Say I just wanna copy the text I’ve circled in the image above, is this possible? Or do I also have to copy everything to the left of the block I want to copy?










share|improve this question









New contributor




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
























    up vote
    22
    down vote

    favorite
    3












    Is it possible to copy a "block" of text from a terminal window without having to copy entire lines?



    Example:



    enter image description here



    Say I just wanna copy the text I’ve circled in the image above, is this possible? Or do I also have to copy everything to the left of the block I want to copy?










    share|improve this question









    New contributor




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






















      up vote
      22
      down vote

      favorite
      3









      up vote
      22
      down vote

      favorite
      3






      3





      Is it possible to copy a "block" of text from a terminal window without having to copy entire lines?



      Example:



      enter image description here



      Say I just wanna copy the text I’ve circled in the image above, is this possible? Or do I also have to copy everything to the left of the block I want to copy?










      share|improve this question









      New contributor




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











      Is it possible to copy a "block" of text from a terminal window without having to copy entire lines?



      Example:



      enter image description here



      Say I just wanna copy the text I’ve circled in the image above, is this possible? Or do I also have to copy everything to the left of the block I want to copy?







      macos terminal copy-paste






      share|improve this question









      New contributor




      Mended 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 question









      New contributor




      Mended 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 question




      share|improve this question








      edited Dec 15 at 3:49









      Monomeeth

      45.3k796137




      45.3k796137






      New contributor




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









      asked Dec 14 at 10:38









      Mended

      1113




      1113




      New contributor




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





      New contributor





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






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






















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          27
          down vote













          You should be able to do this by holding the option key down while doing it. This changes the cursor to a '+' sign and allows you to select any rectangular area of text.



          See screenshot below:



          enter image description here



          If you look at the above image closely, you'll see in the left window I've highlighted a block of text in Terminal and in the right window I've been able to paste this text into a new TextEdit document.






          share|improve this answer



















          • 2




            This doesn't work in iTerm but works fine in Terminal.
            – jmh
            Dec 14 at 15:14


















          up vote
          7
          down vote













          When using iTerm2, you can either use Cmd+Option+mouse to perform vertical/block selection, which transforms your cursor into a cross, similar to Terminal.app.



          Or you can use copy mode:





          • Cmd+Shift+C to enter copy mode


          • Ctrl+v to enter vertical/block mode

          • Move the cursor using the cursor keys on the keyboard (see link for more movement options)

          • Once you’re done, use Ctrl+k, y to copy the selection.






          share|improve this answer




























            up vote
            6
            down vote













            You might also try using awk to limit the shell output to what you want. You could then even pipe it to pbcopy






            share|improve this answer

















            • 2




              Or just cut -c 56- or so.
              – Wildcard
              Dec 15 at 2:46











            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "118"
            };
            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
            });


            }
            });






            Mended is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fapple.stackexchange.com%2fquestions%2f345611%2fcopying-blocks-of-text-in-terminal%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            27
            down vote













            You should be able to do this by holding the option key down while doing it. This changes the cursor to a '+' sign and allows you to select any rectangular area of text.



            See screenshot below:



            enter image description here



            If you look at the above image closely, you'll see in the left window I've highlighted a block of text in Terminal and in the right window I've been able to paste this text into a new TextEdit document.






            share|improve this answer



















            • 2




              This doesn't work in iTerm but works fine in Terminal.
              – jmh
              Dec 14 at 15:14















            up vote
            27
            down vote













            You should be able to do this by holding the option key down while doing it. This changes the cursor to a '+' sign and allows you to select any rectangular area of text.



            See screenshot below:



            enter image description here



            If you look at the above image closely, you'll see in the left window I've highlighted a block of text in Terminal and in the right window I've been able to paste this text into a new TextEdit document.






            share|improve this answer



















            • 2




              This doesn't work in iTerm but works fine in Terminal.
              – jmh
              Dec 14 at 15:14













            up vote
            27
            down vote










            up vote
            27
            down vote









            You should be able to do this by holding the option key down while doing it. This changes the cursor to a '+' sign and allows you to select any rectangular area of text.



            See screenshot below:



            enter image description here



            If you look at the above image closely, you'll see in the left window I've highlighted a block of text in Terminal and in the right window I've been able to paste this text into a new TextEdit document.






            share|improve this answer














            You should be able to do this by holding the option key down while doing it. This changes the cursor to a '+' sign and allows you to select any rectangular area of text.



            See screenshot below:



            enter image description here



            If you look at the above image closely, you'll see in the left window I've highlighted a block of text in Terminal and in the right window I've been able to paste this text into a new TextEdit document.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Dec 14 at 11:07

























            answered Dec 14 at 10:40









            Monomeeth

            45.3k796137




            45.3k796137








            • 2




              This doesn't work in iTerm but works fine in Terminal.
              – jmh
              Dec 14 at 15:14














            • 2




              This doesn't work in iTerm but works fine in Terminal.
              – jmh
              Dec 14 at 15:14








            2




            2




            This doesn't work in iTerm but works fine in Terminal.
            – jmh
            Dec 14 at 15:14




            This doesn't work in iTerm but works fine in Terminal.
            – jmh
            Dec 14 at 15:14












            up vote
            7
            down vote













            When using iTerm2, you can either use Cmd+Option+mouse to perform vertical/block selection, which transforms your cursor into a cross, similar to Terminal.app.



            Or you can use copy mode:





            • Cmd+Shift+C to enter copy mode


            • Ctrl+v to enter vertical/block mode

            • Move the cursor using the cursor keys on the keyboard (see link for more movement options)

            • Once you’re done, use Ctrl+k, y to copy the selection.






            share|improve this answer

























              up vote
              7
              down vote













              When using iTerm2, you can either use Cmd+Option+mouse to perform vertical/block selection, which transforms your cursor into a cross, similar to Terminal.app.



              Or you can use copy mode:





              • Cmd+Shift+C to enter copy mode


              • Ctrl+v to enter vertical/block mode

              • Move the cursor using the cursor keys on the keyboard (see link for more movement options)

              • Once you’re done, use Ctrl+k, y to copy the selection.






              share|improve this answer























                up vote
                7
                down vote










                up vote
                7
                down vote









                When using iTerm2, you can either use Cmd+Option+mouse to perform vertical/block selection, which transforms your cursor into a cross, similar to Terminal.app.



                Or you can use copy mode:





                • Cmd+Shift+C to enter copy mode


                • Ctrl+v to enter vertical/block mode

                • Move the cursor using the cursor keys on the keyboard (see link for more movement options)

                • Once you’re done, use Ctrl+k, y to copy the selection.






                share|improve this answer












                When using iTerm2, you can either use Cmd+Option+mouse to perform vertical/block selection, which transforms your cursor into a cross, similar to Terminal.app.



                Or you can use copy mode:





                • Cmd+Shift+C to enter copy mode


                • Ctrl+v to enter vertical/block mode

                • Move the cursor using the cursor keys on the keyboard (see link for more movement options)

                • Once you’re done, use Ctrl+k, y to copy the selection.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 14 at 18:17









                Konrad Rudolph

                1,18221026




                1,18221026






















                    up vote
                    6
                    down vote













                    You might also try using awk to limit the shell output to what you want. You could then even pipe it to pbcopy






                    share|improve this answer

















                    • 2




                      Or just cut -c 56- or so.
                      – Wildcard
                      Dec 15 at 2:46















                    up vote
                    6
                    down vote













                    You might also try using awk to limit the shell output to what you want. You could then even pipe it to pbcopy






                    share|improve this answer

















                    • 2




                      Or just cut -c 56- or so.
                      – Wildcard
                      Dec 15 at 2:46













                    up vote
                    6
                    down vote










                    up vote
                    6
                    down vote









                    You might also try using awk to limit the shell output to what you want. You could then even pipe it to pbcopy






                    share|improve this answer












                    You might also try using awk to limit the shell output to what you want. You could then even pipe it to pbcopy







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Dec 14 at 13:23









                    Vinnie James

                    1845




                    1845








                    • 2




                      Or just cut -c 56- or so.
                      – Wildcard
                      Dec 15 at 2:46














                    • 2




                      Or just cut -c 56- or so.
                      – Wildcard
                      Dec 15 at 2:46








                    2




                    2




                    Or just cut -c 56- or so.
                    – Wildcard
                    Dec 15 at 2:46




                    Or just cut -c 56- or so.
                    – Wildcard
                    Dec 15 at 2:46










                    Mended is a new contributor. Be nice, and check out our Code of Conduct.










                    draft saved

                    draft discarded


















                    Mended is a new contributor. Be nice, and check out our Code of Conduct.













                    Mended is a new contributor. Be nice, and check out our Code of Conduct.












                    Mended is a new contributor. Be nice, and check out our Code of Conduct.
















                    Thanks for contributing an answer to Ask Different!


                    • 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.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • 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%2fapple.stackexchange.com%2fquestions%2f345611%2fcopying-blocks-of-text-in-terminal%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

                    List directoties down one level, excluding some named directories and files

                    list processes belonging to a network namespace

                    list systemd RuntimeDirectory mounts