Emacs: Eshell: Fix load order and aliases
parent
a000f83710
commit
4790312842
|
@ -237,7 +237,10 @@ e-mail."
|
|||
|
||||
;;; Eshell
|
||||
(add-to-list 'package-selected-packages 'pcomplete-extension)
|
||||
(add-hook 'eshell-load-hook (lambda () (require 'mode-eshell)))
|
||||
;;; `eshell-first-time-mode-hook' is run too late to remove modules globally, so we do it here.
|
||||
(with-eval-after-load 'em-banner
|
||||
(setq-default eshell-modules-list (delq 'eshell-banner eshell-modules-list)))
|
||||
(add-hook 'eshell-first-time-mode-hook (lambda () (require 'mode-eshell)))
|
||||
|
||||
;;; Evil
|
||||
(add-to-list 'package-selected-packages 'evil)
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
;;; Eshell
|
||||
|
||||
;;; This mode has a lot of hooks.
|
||||
;;; `emacs-load-hook' is run at the very beginning; not all variables/functions will be set.
|
||||
;;; `emacs-mode-hook' is run once everything is loaded.
|
||||
;;; `eshell-load-hook' is run at the very beginning; not all variables/functions will be set.
|
||||
;;; Use `eshell-first-time-mode-hook' to customize once everything is loaded.
|
||||
;;; `eshell-mode-hook' is run once per session.
|
||||
|
||||
;;; TODO: Bind "ls"? No need if we have Ctrl-e?
|
||||
;; (local-set-key "\C-l" 'eshell/ls)
|
||||
|
||||
(setq
|
||||
eshell-directory-name (concat emacs-cache-folder "eshell")
|
||||
eshell-banner-message ""
|
||||
eshell-ls-use-colors t
|
||||
eshell-destroy-buffer-when-process-dies t
|
||||
;; TODO: Hour is printed twice. We don't need to set this?
|
||||
;; eshell-ls-date-format (replace-regexp-in-string "^\\+*" "" (getenv "TIME_STYLE"))
|
||||
)
|
||||
eshell-destroy-buffer-when-process-dies t)
|
||||
|
||||
;; TODO: Hour is printed twice. We don't need to set this?
|
||||
;; (setq eshell-ls-date-format (replace-regexp-in-string "^\\+*" "" (getenv "TIME_STYLE")))
|
||||
|
||||
;;; Leave `eshell-highlight-prompt' to t as it sets the read-only property.
|
||||
(setq eshell-prompt-function
|
||||
|
@ -29,12 +29,12 @@
|
|||
" "))))
|
||||
;;; If the prompt spans over multiple lines, the regexp should match
|
||||
;;; last line only.
|
||||
(setq eshell-prompt-regexp "^> ")
|
||||
;;; Warning: This is a local variable.
|
||||
(setq eshell-prompt-regexp (setq-default eshell-prompt-regexp "^> "))
|
||||
|
||||
(with-eval-after-load 'em-term
|
||||
(nconc eshell-visual-commands
|
||||
'("abook" "cmus" "fzf" "htop" "mpv" "mutt" "ncdu" "newsbeuter" "ranger"))
|
||||
(add-to-list 'eshell-visual-subcommands '("git" "log" "diff" "show")))
|
||||
(nconc eshell-visual-commands
|
||||
'("abook" "cmus" "fzf" "htop" "mpv" "mutt" "ncdu" "newsbeuter" "ranger"))
|
||||
(add-to-list 'eshell-visual-subcommands '("git" "log" "diff" "show"))
|
||||
|
||||
;;; Alias management possibilities:
|
||||
;;; - Version eshell-alias and store it in user-emacs-directory. Simplest and
|
||||
|
@ -47,27 +47,28 @@
|
|||
;;; Let's write manually instead.
|
||||
;;; TODO: Add pacman functions from fish config.
|
||||
;;; TODO: Compare system tools and lisp equivalents of ls and grep.
|
||||
(with-eval-after-load 'em-alias
|
||||
(eshell-read-aliases-list)
|
||||
(dolist (alias '(
|
||||
;; ("ls" "ls -F $*")
|
||||
("l" "ls -1 $*")
|
||||
("la" "ls -lAh $*")
|
||||
("ll" "ls -lh $*")
|
||||
;; ("grep" "grep --color=auto")
|
||||
("cal" "cal -m $*")
|
||||
("cp" "cp -i $*")
|
||||
("mv" "mv -i $*")
|
||||
("mkdir" "mkdir -p $*")
|
||||
("mkcd" "mkdir -p $* && cd $1")
|
||||
;; ("emacs" "find-file $1")
|
||||
("em" "find-file $1")))
|
||||
(add-to-list 'eshell-command-aliases-list alias))
|
||||
(eshell-write-aliases-list))
|
||||
(eshell-read-aliases-list)
|
||||
(dolist
|
||||
(alias
|
||||
'(("l" "ls -1 $*")
|
||||
("la" "ls -lAh $*")
|
||||
("ll" "ls -lh $*")
|
||||
;; ("ls" "ls -F $*")
|
||||
;; ("grep" "grep --color=auto")
|
||||
;; ("cal" "*cal -m $*")
|
||||
;; ("emacs" "find-file $1")
|
||||
;; ("em" "find-file $*")
|
||||
("cp" "*cp -i $*")
|
||||
("mv" "*mv -i $*")
|
||||
("mkdir" "*mkdir -p $*")
|
||||
("mkcd" "*mkdir -p $* && cd $1")))
|
||||
(add-to-list 'eshell-command-aliases-list alias))
|
||||
(eshell-write-aliases-list)
|
||||
|
||||
;;; Emacs' standard function fail when output has empty lines.
|
||||
;;; Emacs' standard functions fail when output has empty lines.
|
||||
;;; This implementation is more reliable.
|
||||
;;; TODO: Report upstream
|
||||
;;; TODO: Test when eshell-highlight-prompt is nil.
|
||||
;;; TODO: Report upstream.
|
||||
(defun eshell-next-prompt (n)
|
||||
"Move to end of Nth next prompt in the buffer.
|
||||
See `eshell-prompt-regexp'."
|
||||
|
|
|
@ -169,11 +169,12 @@
|
|||
(interactive)
|
||||
(eshell-interrupt-process)
|
||||
(evil-insert 1))
|
||||
(defun evil/eshell-define-keys ()
|
||||
|
||||
;;; `eshell-mode-map' is reset when Eshell is initialized in `eshell-mode'. We
|
||||
;;; need to add bindings to `eshell-first-time-mode-hook'.
|
||||
(defun evil/eshell-set-keys ()
|
||||
(with-eval-after-load 'tool-helm
|
||||
(evil-define-key '(normal insert) eshell-mode-map "\C-r" 'helm-eshell-history)
|
||||
(evil-define-key 'insert eshell-mode-map "\C-e" 'helm-find-files))
|
||||
(evil-define-key 'normal eshell-mode-map "i" 'evil/eshell-insert)
|
||||
(evil-define-key 'normal eshell-mode-map "\M-k" 'eshell-previous-prompt)
|
||||
(evil-define-key 'normal eshell-mode-map "\M-j" 'eshell-next-prompt)
|
||||
(evil-define-key 'normal eshell-mode-map "0" 'eshell-bol)
|
||||
|
@ -181,17 +182,18 @@
|
|||
(evil-define-key 'normal eshell-mode-map (kbd "C-c C-c") 'evil/eshell-interrupt-process)
|
||||
(evil-define-key '(normal insert) eshell-mode-map "\M-h" 'eshell-backward-argument)
|
||||
(evil-define-key '(normal insert) eshell-mode-map "\M-l" 'eshell-forward-argument))
|
||||
(add-hook 'eshell-mode-hook 'evil/eshell-define-keys)
|
||||
(add-hook 'eshell-first-time-mode-hook 'evil/eshell-set-keys)
|
||||
|
||||
;; TODO: When point is on "> ", helm-find-files looks up parent folder. Prevent that.
|
||||
|
||||
;; DONE: eshell-mode-map gets reset on new shells. Make it permanent. Hook? Hook looks good:
|
||||
;; https://stackoverflow.com/questions/11946113/emacs-eshell-how-to-read-content-of-command-line-on-pressing-ret
|
||||
|
||||
;; TODO: Cannot kill emacs when eshell has started: "text is read only"
|
||||
;; DONE: Cannot kill emacs when eshell has started: "text is read only"
|
||||
|
||||
;; TODO: Make Evil commands react more dynamically with read-only text.
|
||||
;; Add support for I, C, D, S, s, c*, d*, R, r.
|
||||
;; See https://github.com/emacs-evil/evil/issues/852
|
||||
(defun evil/eshell-delete-whole-line ()
|
||||
(interactive)
|
||||
(if (not (get-text-property (line-beginning-position) 'read-only))
|
||||
|
|
Loading…
Reference in New Issue