Emacs: How to clear a subshell screen?

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











up vote
1
down vote

favorite












In Emacs interactive subshell, when I type clear, the screen is not cleared as it should do in a normal Ubuntu Terminal, for example.



When I press Ctrl + l(twice if the screen is full), the screen gets cleared; but as soon as I type any command, let us say ls, I find myself in the bottom of the page (buffer) meaning that the clearing action is undone.



Is there a way to clear a subshell screen?










share|improve this question

























    up vote
    1
    down vote

    favorite












    In Emacs interactive subshell, when I type clear, the screen is not cleared as it should do in a normal Ubuntu Terminal, for example.



    When I press Ctrl + l(twice if the screen is full), the screen gets cleared; but as soon as I type any command, let us say ls, I find myself in the bottom of the page (buffer) meaning that the clearing action is undone.



    Is there a way to clear a subshell screen?










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      In Emacs interactive subshell, when I type clear, the screen is not cleared as it should do in a normal Ubuntu Terminal, for example.



      When I press Ctrl + l(twice if the screen is full), the screen gets cleared; but as soon as I type any command, let us say ls, I find myself in the bottom of the page (buffer) meaning that the clearing action is undone.



      Is there a way to clear a subshell screen?










      share|improve this question













      In Emacs interactive subshell, when I type clear, the screen is not cleared as it should do in a normal Ubuntu Terminal, for example.



      When I press Ctrl + l(twice if the screen is full), the screen gets cleared; but as soon as I type any command, let us say ls, I find myself in the bottom of the page (buffer) meaning that the clearing action is undone.



      Is there a way to clear a subshell screen?







      shell-mode






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 1 hour ago









      Billal Begueradj

      527




      527




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          You can clear the shell buffer like any other, if you get the cursor away from the current prompt, where its movement behavior is different. Here's one recipe, which feels intuitive to me but looks long when I write it down.




          • <Enter> to get a fresh prompt


          • C-b C-a moves the cursor to the beginning of the current line, to the left of your prompt


          • M-< to execute beginning-of-buffer


          • C-x C-x to execute exchange-point-and-mark, highlighting (nearly) everything in the buffer


          • C-w to execute kill-region

          This gives you a shell buffer containing only (the final line of) the empty prompt you made at the start; you can put the cursor back in the usual place with C-e.



          You can also trim outputs partially by using C-c C-n and C-c C-p to move through your command history from prompt to prompt, using C-<Space> to toggle the mark while moving and selectively highlight command output you no longer need, and C-w to kill highlighted regions.
          This is convenient if you have some command history that you mostly want to keep, but you've accidentally run some verbose command whose output you're no longer interested in. More flexible than killing your entire history.



          Unlike in console shells, your current method of C-l C-l isn't actually clearing anything; it's running recenter-top-bottom twice, which you can do in any shell or non-shell Emacs buffer.






          share|improve this answer








          New contributor




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
























            up vote
            1
            down vote













            eshell-postoutput-scroll-to-bottom in the hook eshell-output-filter-functions is causing to scroll to bottom and so to remove it from the hook add this snippet to emacs config



            (add-hook 'eshell-mode-hook
            (defun rm-eshell-postoutput-scroll-to-bottom ()
            (remove-hook 'eshell-output-filter-functions
            'eshell-postoutput-scroll-to-bottom)))


            after this you can use C-l C-l to clear screen in eshell and proceed with any commands without scroll






            share|improve this answer




















              Your Answer







              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "583"
              ;
              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%2femacs.stackexchange.com%2fquestions%2f45279%2femacs-how-to-clear-a-subshell-screen%23new-answer', 'question_page');

              );

              Post as a guest






























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              1
              down vote



              accepted










              You can clear the shell buffer like any other, if you get the cursor away from the current prompt, where its movement behavior is different. Here's one recipe, which feels intuitive to me but looks long when I write it down.




              • <Enter> to get a fresh prompt


              • C-b C-a moves the cursor to the beginning of the current line, to the left of your prompt


              • M-< to execute beginning-of-buffer


              • C-x C-x to execute exchange-point-and-mark, highlighting (nearly) everything in the buffer


              • C-w to execute kill-region

              This gives you a shell buffer containing only (the final line of) the empty prompt you made at the start; you can put the cursor back in the usual place with C-e.



              You can also trim outputs partially by using C-c C-n and C-c C-p to move through your command history from prompt to prompt, using C-<Space> to toggle the mark while moving and selectively highlight command output you no longer need, and C-w to kill highlighted regions.
              This is convenient if you have some command history that you mostly want to keep, but you've accidentally run some verbose command whose output you're no longer interested in. More flexible than killing your entire history.



              Unlike in console shells, your current method of C-l C-l isn't actually clearing anything; it's running recenter-top-bottom twice, which you can do in any shell or non-shell Emacs buffer.






              share|improve this answer








              New contributor




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





















                up vote
                1
                down vote



                accepted










                You can clear the shell buffer like any other, if you get the cursor away from the current prompt, where its movement behavior is different. Here's one recipe, which feels intuitive to me but looks long when I write it down.




                • <Enter> to get a fresh prompt


                • C-b C-a moves the cursor to the beginning of the current line, to the left of your prompt


                • M-< to execute beginning-of-buffer


                • C-x C-x to execute exchange-point-and-mark, highlighting (nearly) everything in the buffer


                • C-w to execute kill-region

                This gives you a shell buffer containing only (the final line of) the empty prompt you made at the start; you can put the cursor back in the usual place with C-e.



                You can also trim outputs partially by using C-c C-n and C-c C-p to move through your command history from prompt to prompt, using C-<Space> to toggle the mark while moving and selectively highlight command output you no longer need, and C-w to kill highlighted regions.
                This is convenient if you have some command history that you mostly want to keep, but you've accidentally run some verbose command whose output you're no longer interested in. More flexible than killing your entire history.



                Unlike in console shells, your current method of C-l C-l isn't actually clearing anything; it's running recenter-top-bottom twice, which you can do in any shell or non-shell Emacs buffer.






                share|improve this answer








                New contributor




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



















                  up vote
                  1
                  down vote



                  accepted







                  up vote
                  1
                  down vote



                  accepted






                  You can clear the shell buffer like any other, if you get the cursor away from the current prompt, where its movement behavior is different. Here's one recipe, which feels intuitive to me but looks long when I write it down.




                  • <Enter> to get a fresh prompt


                  • C-b C-a moves the cursor to the beginning of the current line, to the left of your prompt


                  • M-< to execute beginning-of-buffer


                  • C-x C-x to execute exchange-point-and-mark, highlighting (nearly) everything in the buffer


                  • C-w to execute kill-region

                  This gives you a shell buffer containing only (the final line of) the empty prompt you made at the start; you can put the cursor back in the usual place with C-e.



                  You can also trim outputs partially by using C-c C-n and C-c C-p to move through your command history from prompt to prompt, using C-<Space> to toggle the mark while moving and selectively highlight command output you no longer need, and C-w to kill highlighted regions.
                  This is convenient if you have some command history that you mostly want to keep, but you've accidentally run some verbose command whose output you're no longer interested in. More flexible than killing your entire history.



                  Unlike in console shells, your current method of C-l C-l isn't actually clearing anything; it's running recenter-top-bottom twice, which you can do in any shell or non-shell Emacs buffer.






                  share|improve this answer








                  New contributor




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









                  You can clear the shell buffer like any other, if you get the cursor away from the current prompt, where its movement behavior is different. Here's one recipe, which feels intuitive to me but looks long when I write it down.




                  • <Enter> to get a fresh prompt


                  • C-b C-a moves the cursor to the beginning of the current line, to the left of your prompt


                  • M-< to execute beginning-of-buffer


                  • C-x C-x to execute exchange-point-and-mark, highlighting (nearly) everything in the buffer


                  • C-w to execute kill-region

                  This gives you a shell buffer containing only (the final line of) the empty prompt you made at the start; you can put the cursor back in the usual place with C-e.



                  You can also trim outputs partially by using C-c C-n and C-c C-p to move through your command history from prompt to prompt, using C-<Space> to toggle the mark while moving and selectively highlight command output you no longer need, and C-w to kill highlighted regions.
                  This is convenient if you have some command history that you mostly want to keep, but you've accidentally run some verbose command whose output you're no longer interested in. More flexible than killing your entire history.



                  Unlike in console shells, your current method of C-l C-l isn't actually clearing anything; it's running recenter-top-bottom twice, which you can do in any shell or non-shell Emacs buffer.







                  share|improve this answer








                  New contributor




                  rob 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




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









                  answered 1 hour ago









                  rob

                  1263




                  1263




                  New contributor




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





                  New contributor





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






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




















                      up vote
                      1
                      down vote













                      eshell-postoutput-scroll-to-bottom in the hook eshell-output-filter-functions is causing to scroll to bottom and so to remove it from the hook add this snippet to emacs config



                      (add-hook 'eshell-mode-hook
                      (defun rm-eshell-postoutput-scroll-to-bottom ()
                      (remove-hook 'eshell-output-filter-functions
                      'eshell-postoutput-scroll-to-bottom)))


                      after this you can use C-l C-l to clear screen in eshell and proceed with any commands without scroll






                      share|improve this answer
























                        up vote
                        1
                        down vote













                        eshell-postoutput-scroll-to-bottom in the hook eshell-output-filter-functions is causing to scroll to bottom and so to remove it from the hook add this snippet to emacs config



                        (add-hook 'eshell-mode-hook
                        (defun rm-eshell-postoutput-scroll-to-bottom ()
                        (remove-hook 'eshell-output-filter-functions
                        'eshell-postoutput-scroll-to-bottom)))


                        after this you can use C-l C-l to clear screen in eshell and proceed with any commands without scroll






                        share|improve this answer






















                          up vote
                          1
                          down vote










                          up vote
                          1
                          down vote









                          eshell-postoutput-scroll-to-bottom in the hook eshell-output-filter-functions is causing to scroll to bottom and so to remove it from the hook add this snippet to emacs config



                          (add-hook 'eshell-mode-hook
                          (defun rm-eshell-postoutput-scroll-to-bottom ()
                          (remove-hook 'eshell-output-filter-functions
                          'eshell-postoutput-scroll-to-bottom)))


                          after this you can use C-l C-l to clear screen in eshell and proceed with any commands without scroll






                          share|improve this answer












                          eshell-postoutput-scroll-to-bottom in the hook eshell-output-filter-functions is causing to scroll to bottom and so to remove it from the hook add this snippet to emacs config



                          (add-hook 'eshell-mode-hook
                          (defun rm-eshell-postoutput-scroll-to-bottom ()
                          (remove-hook 'eshell-output-filter-functions
                          'eshell-postoutput-scroll-to-bottom)))


                          after this you can use C-l C-l to clear screen in eshell and proceed with any commands without scroll







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 14 mins ago









                          junnu

                          1338




                          1338



























                               

                              draft saved


                              draft discarded















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2femacs.stackexchange.com%2fquestions%2f45279%2femacs-how-to-clear-a-subshell-screen%23new-answer', 'question_page');

                              );

                              Post as a guest













































































                              Comments

                              Popular posts from this blog

                              What does second last employer means? [closed]

                              Installing NextGIS Connect into QGIS 3?

                              One-line joke