為 emacs 自訂 eshell-prompt-function 時遺失功能

為 emacs 自訂 eshell-prompt-function 時遺失功能

我想像在命令列上那樣從 eshell 提示中隱藏當前工作目錄,因為它佔用了大量的螢幕空間。使用C-h vi 檢查預設值是:

Value:
(lambda nil
  (concat
   (eshell/pwd)
   (if
       (=
        (user-uid)
        0)
       " # " " $ ")))

我嘗試在我的中將其更改為.emacs

(setq eshell-prompt-function
      (lambda () "> "))

但是當我執行上述操作時,某些鍵會損壞。例如,我無法再使用它M-p來瀏覽先前的命令,並且C-c C-a不會像使用預設提示符號那樣將指向我輸入的命令的開頭。我想知道為什麼會發生這種情況,是否有解決方法?

謝謝

答案1

eshell-bol 使用 eshell-skip-prompt 函數來繞過提示。由於您已將提示更改為以 > 而不是 $ 結尾,因此您需要更改 eshell-prompt-regexp 的值。將其更改為^>應該允許它工作。

eshell-prompt-regexp is a variable defined in `em-prompt.el'.
Its value is "^[^#$
]* [#$] "

Documentation:
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.

You can customize this variable.

相關內容