(provide 'thoom-eshell) (use-package eat :ensure t :custom (eat-term-name "xterm-256color") :init (eval-after-load 'eshell #'eat-eshell-mode) (eval-after-load 'eshell #'eat-eshell-visual-command-mode) :config (add-to-list 'eat-semi-char-non-bound-keys (vector meta-prefix-char ?`)) (add-to-list 'eat-semi-char-non-bound-keys [?\C-o]) (eat-update-semi-char-mode-map) (add-to-list 'eat-eshell-semi-char-non-bound-keys (vector meta-prefix-char ?`)) (add-to-list 'eat-eshell-semi-char-non-bound-keys [?\C-o]) (eat-eshell-update-semi-char-mode-map) :hook (eat-mode . (lambda () (setq display-line-numbers nil) (hl-line-mode -1)))) (use-package eshell :config (setq eshell-destroy-buffer-when-process-dies t eshell-visual-commands '() eshell-banner-message "") ;; From https://karthinks.com/software/jumping-directories-in-eshell/ (defun eshell/j (&optional regexp) "Navigate to a previously visited directory in eshell, or to any directory proferred by `consult-dir'." (let ((eshell-dirs (delete-dups (mapcar 'abbreviate-file-name (ring-elements eshell-last-dir-ring))))) (cond ((and (not regexp) (featurep 'consult-dir)) (let* ((consult-dir--source-eshell `(:name "Eshell" :narrow ?e :category file :face consult-file :items ,eshell-dirs)) (consult-dir-sources (cons consult-dir--source-eshell consult-dir-sources))) (eshell/cd (substring-no-properties (consult-dir--pick "Switch directory: "))))) (t (eshell/cd (if regexp (eshell-find-previous-directory regexp) (completing-read "cd: " eshell-dirs)))))))) (use-package eshell :bind (:map eshell-hist-mode-map ("M-r" . consult-history)) :after em-hist) (use-package pcre2el :ensure t :config (defmacro prx (&rest rx-sexp) "Convert rx-compatible regular expressions to PCRE." `(rxt-elisp-to-pcre (rx ,@rx-sexp)))) (use-package eshell-toggle :ensure t :custom (eshell-toggle-size-fraction 2) (eshell-toggle-window-side 'below) :bind (("M-`" . eshell-toggle))) (use-package eshell-p10k :ensure (:host github :repo "elken/eshell-p10k") :config (eshell-p10k-def-segment time "" (format-time-string "%H:%M" (current-time)) 'eshell-p10k-distro-face) (defun num-exitcode-string () (if (= eshell-last-command-status 0) (number-to-string eshell-p10k--prompt-num-index) (format "%d (%d)" eshell-p10k--prompt-num-index eshell-last-command-status))) (defun num-exitcode-face () (if (= eshell-last-command-status 0) 'eshell-p10k-git-clean-face 'eshell-p10k-git-dirty-face)) (eshell-p10k-def-segment num-exitcode "" (num-exitcode-string) (num-exitcode-face)) (defun eshell-p10k-prompt-function () "Prompt defining function." (eshell-p10k-def-prompt '(num-exitcode time dir git))) (setq eshell-prompt-function #'eshell-p10k-prompt-function eshell-prompt-regexp eshell-p10k-prompt-string))