Emacs 26.1, Windows 10 (64 bit)

M-x eshell

Here result:

enter image description here

But it's read only. But I need to type text in any place in any place in eshell.

Also I want to move cursor in any place in eshell buffer. All of this I can do in shell buffer, but can't in eshell buffer. Also I want to change text in any place in eshell buffer.

  • I can do this with eshell on Emacs 27.0.50 on Linux. Can you try this with emacs -Q? Also, can you tell us what operating system you are using? It looks like it's Windows, that might matter. – Tyler Dec 9 '19 at 21:31
  • 1
    also, how are you trying to move your cursor? The arrow keys won't work, but C-n and C-p should. – Tyler Dec 9 '19 at 21:32
  • @Tyler I updated my post – a_subscriber Dec 10 '19 at 8:05
  • @Tyler By C-n and C-p work but it not comfortable. By arrows is better. But with arrows not work in eshell. But in shell buffer work with arrows. – a_subscriber Dec 10 '19 at 8:06
  • Hm, did you actually read my answer? I answered all those questions. With my proposed hook you can use the cursor keys and remove-text-properties-interactive does allow you to edit the prompt strings in the Eshell buffer even if I strongly advised against it. It can be even more catastrophic to edit the prompt strings in the other shell modes. But, if you must... – Tobias Dec 10 '19 at 10:00

You can clear the bindings for the cursor keys in eshell-mode with the following Elisp snippet in your init file.

(defun my-eshell-config ()
  "My Eshell configuration."
  (define-key eshell-mode-map (kbd "<up>") nil)
  (define-key eshell-mode-map (kbd "<down>") nil))

(add-hook 'eshell-mode-hook #'my-eshell-config)

Only the prompt echoes are read-only in eshell-mode. All other output of Eshell and your input are editable.

You should never change the prompt echoes -- especially not the last one -- since they are regexp-matched by eshell.

See the doc-string of eshell-prompt-regexp:

A regexp which fully matches your eshell prompt. This setting is important, since it affects how eshell will interpret the lines that are passed to it. If this variable is changed, all Eshell buffers must be exited and re-entered for it to take effect.

If you occasionally want to modify a prompt echo in spite of good advice, you can use the following command to remove the read-only property from the prompt:

(defun remove-text-properties-interactive (&optional beg end ignore-read-only)
  "Remove text properties in region from BEG to END.
The read-only text property within that region is ignored
if IGNORE-READ-ONLY is non-nil."
  (interactive "r\nP")
    (let ((inhibit-read-only (if ignore-read-only t inhibit-read-only)))
      (set-text-properties beg end nil))))

Since library developers almost always have their good reason to set the read-only text property on stretches of buffer text the removal of the read-only text property must be enforced by the prefix argument C-u. The steps in detail:

  1. Mark the region with the Eshell prompt you want to modify.
  2. Call C-u M-x remove-text-properties-interactive. (Note that the long command name does not hurt very much because of the available tab-completion in the minibuffer.)
  3. Do your modifications on the prompt string.

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.