term/eshell: refactor & update keybinds
- Replace +eshell|init-evil with an advice for evil-collection-eshell-next-prompt-on-insert - Update C-n/C-j and C-p/C-k keybinds to use eshell-{next,previous}-matching-input-from-input, which behave much like zsh's history-substring-search-{up,down} - Move window navigation keybinds C-{h,j,k,l} to C-c {h,j,k,l} (more tmux-esque).
This commit is contained in:
parent
4fec3eb698
commit
a56ce38903
2 changed files with 25 additions and 28 deletions
|
@ -1,15 +1,6 @@
|
|||
;;; term/eshell/autoload/evil.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! :editor evil)
|
||||
|
||||
;;;###autoload
|
||||
(defun +eshell|init-evil ()
|
||||
"Replace `evil-collection-eshell-next-prompt-on-insert' with
|
||||
`+eshell|goto-prompt-on-insert', which ensures the point is on the prompt when
|
||||
changing to insert mode."
|
||||
(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)))
|
||||
|
||||
;;;###autoload (autoload '+eshell:run "term/eshell/autoload/evil" nil t)
|
||||
(evil-define-command +eshell:run (command bang)
|
||||
"TODO"
|
||||
|
@ -23,9 +14,11 @@ changing to insert mode."
|
|||
((+eshell/open-popup nil command)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +eshell|goto-prompt-on-insert ()
|
||||
(defun +eshell*goto-prompt-on-insert ()
|
||||
"Move cursor to the prompt when switching to insert mode (if point isn't
|
||||
already there)."
|
||||
already there).
|
||||
|
||||
Meant to replace `evil-collection-eshell-next-prompt-on-insert'."
|
||||
(when (< (point) eshell-last-output-end)
|
||||
(goto-char
|
||||
(if (memq this-command '(evil-append evil-append-line))
|
||||
|
|
|
@ -22,7 +22,7 @@ buffer.")
|
|||
(defvar +eshell-aliases
|
||||
'(("q" "exit") ; built-in
|
||||
("f" "find-file $1")
|
||||
("bd" "eshell-up $1") ; `eshell-up'
|
||||
("bd" "eshell-up $1")
|
||||
("rg" "rg --color=always $*")
|
||||
("ag" "ag --color=always $*")
|
||||
("l" "ls -lh")
|
||||
|
@ -107,8 +107,7 @@ You should use `set-eshell-alias!' to change this.")
|
|||
;; Visual commands require a proper terminal. Eshell can't handle that, so
|
||||
;; it delegates these commands to a term buffer.
|
||||
(after! em-term
|
||||
(dolist (cmd '("tmux" "htop" "vim" "nvim" "ncmpcpp"))
|
||||
(add-to-list 'eshell-visual-commands cmd)))
|
||||
(pushnew! eshell-visual-commands "tmux" "htop" "vim" "nvim" "ncmpcpp"))
|
||||
|
||||
(defun +eshell|init-aliases ()
|
||||
(setq +eshell--default-aliases eshell-command-aliases-list
|
||||
|
@ -118,29 +117,34 @@ You should use `set-eshell-alias!' to change this.")
|
|||
(add-hook 'eshell-alias-load-hook #'+eshell|init-aliases)
|
||||
|
||||
(when (featurep! :editor evil +everywhere)
|
||||
(add-hook 'eshell-mode-hook #'+eshell|init-evil))
|
||||
(advice-add #'evil-collection-eshell-next-prompt-on-insert :override #'+eshell*goto-prompt-on-insert))
|
||||
|
||||
(defun +eshell|init-keymap ()
|
||||
"Setup eshell keybindings. This must be done in a hook because eshell-mode
|
||||
redefines its keys every time `eshell-mode' is enabled."
|
||||
(map! :map eshell-mode-map
|
||||
:n "RET" #'+eshell/goto-end-of-prompt
|
||||
:n [return] #'+eshell/goto-end-of-prompt
|
||||
:n "c" #'+eshell/evil-change
|
||||
:n "C" #'+eshell/evil-change-line
|
||||
:n "d" #'+eshell/evil-delete
|
||||
:n "D" #'+eshell/evil-delete-line
|
||||
:i "TAB" #'+eshell/pcomplete
|
||||
:i [tab] #'+eshell/pcomplete
|
||||
:i "C-j" #'evil-window-down
|
||||
:i "C-k" #'evil-window-up
|
||||
:i "C-h" #'evil-window-left
|
||||
:i "C-l" #'evil-window-right
|
||||
:i "C-d" #'+eshell/quit-or-delete-char
|
||||
:i "C-p" #'eshell-previous-input
|
||||
:i "C-n" #'eshell-next-input
|
||||
:i "C-p" #'eshell-previous-matching-input-from-input
|
||||
:i "C-k" #'eshell-previous-matching-input-from-input
|
||||
:i "C-j" #'eshell-next-matching-input-from-input
|
||||
:i "C-n" #'eshell-next-matching-input-from-input
|
||||
"C-s" #'+eshell/search-history
|
||||
;; Tmux-esque prefix keybinds
|
||||
"C-c s" #'+eshell/split-below
|
||||
"C-c v" #'+eshell/split-right
|
||||
"C-c x" #'+eshell/kill-and-close
|
||||
"C-c h" #'evil-window-left
|
||||
"C-c j" #'evil-window-down
|
||||
"C-c k" #'evil-window-up
|
||||
"C-c l" #'evil-window-right
|
||||
[remap split-window-below] #'+eshell/split-below
|
||||
[remap split-window-right] #'+eshell/split-right
|
||||
[remap doom/backward-to-bol-or-indent] #'eshell-bol
|
||||
|
@ -151,7 +155,7 @@ redefines its keys every time `eshell-mode' is enabled."
|
|||
|
||||
|
||||
(def-package! eshell-up
|
||||
:commands (eshell-up eshell-up-peek))
|
||||
:commands eshell-up eshell-up-peek)
|
||||
|
||||
|
||||
(def-package! shrink-path
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue