From 60f4a1cc0a459b116e5c5e741eb1444a6612db7a Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Sat, 3 Nov 2018 12:01:34 +0100 Subject: [PATCH] [EShell] Streamling configuration Move all actual configuration to init.el, only leaving function definitions in db-eshell.el. --- init.el | 55 +++++++++++++++++++++++++++++++++++++++++- site-lisp/db-eshell.el | 54 ++--------------------------------------- 2 files changed, 56 insertions(+), 53 deletions(-) diff --git a/init.el b/init.el index 1dde209..dbb68e1 100644 --- a/init.el +++ b/init.el @@ -1671,9 +1671,62 @@ are assumed to be of the form *.crt." (add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m) (add-hook 'shell-mode-hook 'with-editor-export-editor))) +(use-package db-eshell + :commands (eshell-clear-buffer + eshell/default-prompt-function + eshell/gst + eshell-insert-history + pcomplete/git)) + (use-package eshell :commands (eshell) - :config (require 'db-eshell)) + :init (setq eshell-cmpl-cycle-completions nil + eshell-scroll-to-bottom-on-input t + eshell-prefer-lisp-functions nil + eshell-error-if-no-glob t + eshell-hist-ignoredups t + eshell-save-history-on-exit t + eshell-destroy-buffer-when-process-dies t + eshell-prompt-function #'eshell/default-prompt-function + eshell-prompt-regexp "└─[$#] " + eshell-highlight-prompt nil) + :config (progn (require 'em-prompt) + (require 'em-term) + (require 'em-cmpl) + + (setenv "PAGER" "cat") + + (add-to-list 'eshell-command-completions-alist + '("gunzip" "gz\\'")) + + (add-to-list 'eshell-command-completions-alist + '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'")) + + (add-hook 'eshell-mode-hook + 'with-editor-export-editor) + + (add-hook 'eshell-mode-hook + (lambda () + (bind-key "C-a" #'eshell-bol eshell-mode-map) + (bind-key "C-l" #'eshell-clear-buffer eshell-mode-map) + (bind-key "M-r" #'eshell-insert-history eshell-mode-map) + (bind-key "M-P" #'eshell-previous-prompt eshell-mode-map) + (bind-key "M-N" #'eshell-next-prompt eshell-mode-map))) + + ;; Ignoring case when completing file names seems to have a + ;; bug: when a ~ is encountered, it is implicitly expaned by + ;; `pcomplete-insert-entry’, overwriting the prompt as a side + ;; effect. Keeping the case as it is does not seem to have + ;; this issue. This problem occurs by default only on Windows + ;; systems (in all flavors), because this is the only time + ;; `pcomplete-ignore-case’ is non-nil by default. + (when on-windows + (add-to-list 'eshell-mode-hook + (lambda () + (setq pcomplete-ignore-case nil)))) + + + (require 'db-eshell))) (use-package with-editor :commands (with-editor-export-editor)) diff --git a/site-lisp/db-eshell.el b/site-lisp/db-eshell.el index 721fd92..18b98c9 100644 --- a/site-lisp/db-eshell.el +++ b/site-lisp/db-eshell.el @@ -8,22 +8,8 @@ ;;; Code: -(require 'em-prompt) -(require 'em-term) -(require 'em-cmpl) - -;; Customization - -(setq eshell-cmpl-cycle-completions nil - eshell-scroll-to-bottom-on-input t - eshell-prefer-lisp-functions nil - eshell-error-if-no-glob t - eshell-hist-ignoredups t - eshell-save-history-on-exit t - eshell-destroy-buffer-when-process-dies t) - -(setenv "PAGER" "cat") +;; Various (defun eshell-clear-buffer () "Clear terminal." @@ -32,12 +18,6 @@ (erase-buffer) (eshell-send-input))) -(add-to-list 'eshell-command-completions-alist - '("gunzip" "gz\\'")) - -(add-to-list 'eshell-command-completions-alist - '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'")) - (defun eshell/default-prompt-function () "A prompt for eshell of the form @@ -56,13 +36,6 @@ (propertize (abbreviate-file-name (eshell/pwd)) 'face '(:foreground "#dc322f"))))) -(setq eshell-prompt-function #'eshell/default-prompt-function - eshell-prompt-regexp "└─[$#] " - eshell-highlight-prompt nil) - -(add-hook 'eshell-mode-hook - 'with-editor-export-editor) - (defun eshell/gst (&rest args) (magit-status (pop args) nil) (eshell/echo)) @@ -75,31 +48,7 @@ (delete-dups (ring-elements eshell-history-ring))))) -(add-hook 'eshell-mode-hook - (lambda () - (bind-key "C-a" #'eshell-bol eshell-mode-map) - (bind-key "C-l" #'eshell-clear-buffer eshell-mode-map) - (bind-key "M-r" #'eshell-insert-history eshell-mode-map) - (bind-key "M-P" #'eshell-previous-prompt eshell-mode-map) - (bind-key "M-N" #'eshell-next-prompt eshell-mode-map))) - -;; File Completion - -(require 'pcomplete) - -;; Ignoring case when completing file names seems to have a bug: when a ~ is -;; encountered, it is implicitly expaned by `pcomplete-insert-entry’, -;; overwriting the prompt as a side effect. Keeping the case as it is does not -;; seem to have this issue. This problem occurs by default only on Windows -;; systems (in all flavors), because this is the only time -;; `pcomplete-ignore-case’ is non-nil by default. - -(when on-windows - (add-to-list 'eshell-mode-hook - (lambda () - (setq pcomplete-ignore-case nil)))) - ;; Git Completion ;; https://tsdh.wordpress.com/2013/05/31/eshell-completion-for-git-bzr-and-hg/ @@ -159,4 +108,5 @@ ;; End (provide 'db-eshell) + ;;; db-eshell ends here