aboutsummaryrefslogtreecommitdiffstats
path: root/oni-eshell.el
diff options
context:
space:
mode:
authorGravatar Tom Willemse2019-02-26 01:41:59 -0800
committerGravatar Tom Willemse2019-02-26 01:41:59 -0800
commit709d72efbfb96702875210794a833c2157c0dffd (patch)
tree4ba3d85dbe6076308350c55c5b94a7a6a769d0a6 /oni-eshell.el
parent7a2be12e94a2b7e7d6feb89f0d508cce91d89bb1 (diff)
downloademacs-config-709d72efbfb96702875210794a833c2157c0dffd.tar.gz
emacs-config-709d72efbfb96702875210794a833c2157c0dffd.zip
Add oni-eshell
Diffstat (limited to 'oni-eshell.el')
-rw-r--r--oni-eshell.el58
1 files changed, 58 insertions, 0 deletions
diff --git a/oni-eshell.el b/oni-eshell.el
new file mode 100644
index 0000000..3228b7b
--- /dev/null
+++ b/oni-eshell.el
@@ -0,0 +1,58 @@
+;;; oni-eshell.el --- Eshell configuration -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2019 Tom Willemse
+
+;; Author: Tom Willemse <tom@ryuslash.org>
+;; Keywords: local
+;; Version: 20190226014039
+;; Package-Requires: (eshell-fringe-status)
+
+;; 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)
+(require 'em-prompt)
+
+(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))
+
+(add-hook 'eshell-load-hook #'oni-eshell--enable-truncating-buffers)
+(add-hook 'eshell-mode-hook 'eshell-fringe-status-mode)
+(add-hook 'eshell-mode-hook 'goto-address-mode)
+(add-hook 'eshell-first-time-mode-hook #'oni-eshell--set-eshell-C-d)
+
+;;;###autoload(with-eval-after-load 'eshell (require 'oni-eshell))
+
+(provide 'oni-eshell)
+;;; oni-eshell.el ends here