diff options
author | 2016-11-04 13:08:16 +0100 | |
---|---|---|
committer | 2016-11-04 13:08:16 +0100 | |
commit | 6167a906c6586d099c02bb3e5e16e01456b6b5c4 (patch) | |
tree | 49f5e97c98075d05a2cf2d5af616ff31c1e7bf06 /emacs/.emacs.d/init/oni-eshell-init.org | |
parent | 3106af31fe3d0d6c7e4469a5238d44bd8a429800 (diff) | |
download | new-dotfiles-6167a906c6586d099c02bb3e5e16e01456b6b5c4.tar.gz new-dotfiles-6167a906c6586d099c02bb3e5e16e01456b6b5c4.zip |
Make C-d quit eshell when appropriate
Diffstat (limited to 'emacs/.emacs.d/init/oni-eshell-init.org')
-rw-r--r-- | emacs/.emacs.d/init/oni-eshell-init.org | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/emacs/.emacs.d/init/oni-eshell-init.org b/emacs/.emacs.d/init/oni-eshell-init.org index 143c140..2e77ae1 100644 --- a/emacs/.emacs.d/init/oni-eshell-init.org +++ b/emacs/.emacs.d/init/oni-eshell-init.org @@ -23,3 +23,23 @@ Show the status of each command in the fringe of the eshell buffer. #+BEGIN_SRC emacs-lisp (add-hook 'eshell-mode-hook 'eshell-fringe-status-mode) #+END_SRC + +Close the buffer when C-d is pressed and we're at the end of the +buffer. + +#+BEGIN_SRC emacs-lisp + (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:set-eshell-C-d () + (define-key eshell-mode-map (kbd "C-d") #'oni:eshell-C-d)) + + (add-hook 'eshell-load-hook #'oni:set-eshell-C-d) +#+END_SRC |