Better move-to-prompt-on-insert-mode hook for eshell
This commit is contained in:
parent
177bf2a9de
commit
c1c3a0987c
2 changed files with 18 additions and 0 deletions
|
@ -1,6 +1,16 @@
|
||||||
;;; tools/eshell/autoload/evil.el -*- lexical-binding: t; -*-
|
;;; tools/eshell/autoload/evil.el -*- lexical-binding: t; -*-
|
||||||
;;;###if (featurep! :feature evil)
|
;;;###if (featurep! :feature evil)
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +eshell|goto-prompt-on-insert ()
|
||||||
|
"Move cursor to the prompt when switching to insert mode (if point isn't
|
||||||
|
already there)."
|
||||||
|
(when (< (point) eshell-last-output-end)
|
||||||
|
(goto-char
|
||||||
|
(if (memq this-command '(evil-append evil-append-line))
|
||||||
|
(point-max)
|
||||||
|
eshell-last-output-end))))
|
||||||
|
|
||||||
;;;###autoload (autoload '+eshell:run "tools/eshell/autoload/evil" nil t)
|
;;;###autoload (autoload '+eshell:run "tools/eshell/autoload/evil" nil t)
|
||||||
(evil-define-command +eshell:run (command bang)
|
(evil-define-command +eshell:run (command bang)
|
||||||
;; TODO Add COMMAND support
|
;; TODO Add COMMAND support
|
||||||
|
|
|
@ -44,6 +44,14 @@
|
||||||
(append eshell-visual-commands '("tmux" "htop" "bash" "zsh" "fish" "vim" "nvim"))
|
(append eshell-visual-commands '("tmux" "htop" "bash" "zsh" "fish" "vim" "nvim"))
|
||||||
eshell-visual-subcommands '(("git" "log" "l" "diff" "show"))))
|
eshell-visual-subcommands '(("git" "log" "l" "diff" "show"))))
|
||||||
|
|
||||||
|
(defun +eshell|init-evil ()
|
||||||
|
"Replace `evil-collection-eshell-next-prompt-on-insert' with
|
||||||
|
`+eshell|goto-prompt-on-insert'."
|
||||||
|
(dolist (hook '(evil-replace-state-entry-hook evil-insert-state-entry-hook))
|
||||||
|
(remove-hook hook 'evil-collection-eshell-next-prompt-on-insert t)
|
||||||
|
(add-hook hook '+eshell|goto-prompt-on-insert nil t)))
|
||||||
|
(add-hook 'eshell-mode-hook #'+eshell|init-evil)
|
||||||
|
|
||||||
(defun +eshell|init-keymap ()
|
(defun +eshell|init-keymap ()
|
||||||
"Setup eshell keybindings. This must be done in a hook because eshell-mode
|
"Setup eshell keybindings. This must be done in a hook because eshell-mode
|
||||||
redefines its keys every time `eshell-mode' is enabled."
|
redefines its keys every time `eshell-mode' is enabled."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue