5

when I execute a command on eshell the prompt switches to the bottom of the window. I have to C-l a few times to get it back on top. Once again after I execute anything it goes back to the bottom of the window. It is infuriating. How do I make sure the eshell prompt stays on 'top' of the window at all times with the previous commands being hidden above the window. I don't know if 'window' is correct terminology. Please correct me if not.

3

You can disable the Eshell's scroll feature using:

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

Notes, (eval-after-load "eshell" (remove-hook ...)) doesn't work correctly according to my experiment, it simply sets eshell-output-filter-functions to nil, I don't know the cause. You can also use the Custom interface with:

M-x customize-option RET eshell-output-filter-functions RET

this way works too and is much easier, since this option is available until Eshell has been invoked, if you can't find this option, type M-x eshell then try again.

6
  • I do not have eshell-output-filter-functions option available. What should I do?
    – 46_and_2
    Nov 22 '16 at 6:45
  • 1
    @JackDawkins I am not sure what's your meaning. Emacs 24.3 has this option, probably some earlier versions has it too. Besides, the option is only available AFTER Eshell has been invoked.
    – xuchunyang
    Nov 22 '16 at 6:58
  • Yes, indeed it worked after I invoked eshell. Thanks.
    – 46_and_2
    Nov 22 '16 at 7:06
  • Well it goes back to doing what it did before in the middle of an editing session. scrolls to the bottom. I made sure I 'apply and save' it. Why is this happening?
    – 46_and_2
    Nov 22 '16 at 8:01
  • I usually execute clear command in zsh when my workspace gets cluttered. I did the same in eshell. The saved setting gets deleted when I do this it seems
    – 46_and_2
    Nov 22 '16 at 8:19
3

You might check whether eshell-scroll-to-bottom-on-output is set to nil. Here's the documentation:

Documentation: Controls whether interpreter output causes window to scroll. If nil, then do not scroll. If t or ‘all’, scroll all windows showing buffer. If ‘this’, scroll only the selected window. If ‘others’, scroll only those that are not the selected window.

4
  • Where exactly do I change this?. I don't have any customizations for eshell on my .emacs.d/init.el file.
    – 46_and_2
    Nov 22 '16 at 6:47
  • If you do M-x Customize and then type eshell it will take you to the customize screen. Scroll down and you'll see the setting. Or alternately, just put (setq eshell-scroll-to-bottom-on-output nil) in your init.el file.
    – mclear
    Nov 22 '16 at 7:56
  • It gives me the following four options.1. Do not scroll eshell windows. 2. scroll all windows showing the buffer 3. scroll only the selected window. 4. scroll all windows other than selected. Which one should I choose?. I am confused.
    – 46_and_2
    Nov 22 '16 at 8:06
  • Since you don't want to go to the bottom of the window it should be set to 1. do not scroll. Or you can do the setq option that I mention above.
    – mclear
    Nov 22 '16 at 20:06
0

You need to set eshell-scroll-show-maximum-output to nil.

Sadly the documentation doesn't really explain the difference to eshell-scroll-to-bottom-on-output, but its default value is nil anyway and therefore isn't responsible for the described behaviour. In contrast the default of eshell-scroll-show-maximum-output is t.

My understanding is that enabling eshell-scroll-to-bottom-on-output causes eshell to scroll to the bottom if you have scrolled upwards the buffer and you have a program running which produces some output. It will just scroll in a way though, that the last line will be visible in the buffer, and will not align the last line to the bottom of the window.

An enabled eshell-scroll-show-maximum-output on the other hand ignores output produced by a third party program when you scroll upwards, but will align the current prompt with the bottom of the window (hence "maximising" the last output) when you issue any kind of input with triggers a new prompt.

1
  • Please consider elaborating, explaining how this answers the question.
    – Drew
    Nov 11 '20 at 1:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.