2019-02-26 10:41:59 +01:00
|
|
|
|
;;; oni-eshell.el --- Eshell configuration -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
|
|
;; Copyright (C) 2019 Tom Willemse
|
|
|
|
|
|
|
|
|
|
;; Author: Tom Willemse <tom@ryuslash.org>
|
|
|
|
|
;; Keywords: local
|
2019-09-20 02:33:38 +02:00
|
|
|
|
;; Version: 2019.0919.172336
|
|
|
|
|
;; Package-Requires: (eshell-fringe-status esh-autosuggest xterm-color)
|
2019-02-26 10:41:59 +01:00
|
|
|
|
|
|
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;; Eshell configuration.
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
|
|
(require 'eshell)
|
2019-09-20 02:33:38 +02:00
|
|
|
|
|
2019-02-26 10:41:59 +01:00
|
|
|
|
(require 'em-prompt)
|
2019-05-31 16:48:35 +02:00
|
|
|
|
(require 'esh-autosuggest)
|
2019-09-20 02:33:38 +02:00
|
|
|
|
(require 'xterm-color)
|
2019-02-26 10:41:59 +01:00
|
|
|
|
|
|
|
|
|
(defun oni-eshell--C-d ()
|
|
|
|
|
"Call `delete-char' or close the buffer if it fails."
|
|
|
|
|
(interactive)
|
|
|
|
|
(condition-case err
|
|
|
|
|
(call-interactively #'delete-char)
|
|
|
|
|
(error (if (and (eq (car err) 'end-of-buffer)
|
|
|
|
|
(looking-back eshell-prompt-regexp nil))
|
|
|
|
|
(kill-buffer)
|
|
|
|
|
(signal (car err) (cdr err))))))
|
|
|
|
|
|
|
|
|
|
(defun oni-eshell--enable-truncating-buffers ()
|
|
|
|
|
"Add `eshell-truncate-buffer' to `eshell-output-filter-functions'."
|
|
|
|
|
(add-to-list 'eshell-output-filter-functions 'eshell-truncate-buffer))
|
|
|
|
|
|
|
|
|
|
(defun oni-eshell--set-eshell-C-d ()
|
|
|
|
|
"Set `C-d' to quit eshell if used at end of prompt."
|
|
|
|
|
(define-key eshell-mode-map (kbd "C-d") #'oni-eshell--C-d))
|
|
|
|
|
|
2019-09-20 02:33:38 +02:00
|
|
|
|
(defun oni-eshell--set-xterm-variables ()
|
|
|
|
|
"Set ‘xterm-color-preserve-properties’ to t."
|
|
|
|
|
(setq xterm-color-preserve-properties t))
|
|
|
|
|
|
2019-05-31 16:48:35 +02:00
|
|
|
|
(add-hook 'eshell-first-time-mode-hook #'oni-eshell--set-eshell-C-d)
|
2019-02-26 10:41:59 +01:00
|
|
|
|
(add-hook 'eshell-load-hook #'oni-eshell--enable-truncating-buffers)
|
2019-05-31 16:48:35 +02:00
|
|
|
|
(add-hook 'eshell-mode-hook 'esh-autosuggest-mode)
|
2019-02-26 10:41:59 +01:00
|
|
|
|
(add-hook 'eshell-mode-hook 'goto-address-mode)
|
2019-09-20 02:33:38 +02:00
|
|
|
|
(add-hook 'eshell-before-prompt-hook #'oni-eshell--set-xterm-variables)
|
2019-02-26 10:41:59 +01:00
|
|
|
|
|
2019-05-31 16:49:43 +02:00
|
|
|
|
(when (display-graphic-p)
|
|
|
|
|
(add-hook 'eshell-mode-hook 'eshell-fringe-status-mode))
|
2019-02-26 11:19:53 +01:00
|
|
|
|
|
2019-09-20 02:33:38 +02:00
|
|
|
|
(add-to-list 'eshell-preoutput-filter-functions 'xterm-color-filter)
|
|
|
|
|
|
|
|
|
|
(setq eshell-output-filter-functions
|
|
|
|
|
(remove 'eshell-handle-ansi-color eshell-output-filter-functions))
|
|
|
|
|
|
|
|
|
|
(setenv "TERM" "xterm-256color")
|
|
|
|
|
|
2019-09-09 01:53:11 +02:00
|
|
|
|
(add-to-list 'display-buffer-alist
|
|
|
|
|
'("\\`\\*eshell" display-buffer-in-side-window
|
|
|
|
|
(side . bottom)
|
|
|
|
|
(slot . 0)
|
|
|
|
|
(window-height . 0.33)))
|
|
|
|
|
|
2019-02-26 10:41:59 +01:00
|
|
|
|
;;;###autoload(with-eval-after-load 'eshell (require 'oni-eshell))
|
|
|
|
|
|
|
|
|
|
(provide 'oni-eshell)
|
|
|
|
|
;;; oni-eshell.el ends here
|