Move eshell popup function to `db-eshell'
That's where it belongs.
This commit is contained in:
parent
32b424de24
commit
5009eb39f9
4
init.el
4
init.el
|
@ -556,7 +556,6 @@
|
|||
db/delete-trailing-whitespace-maybe
|
||||
db/show-current-org-task
|
||||
db/run-or-hide-shell
|
||||
db/run-or-hide-eshell
|
||||
db/run-or-hide-ansi-term
|
||||
db/hex-to-ascii
|
||||
db/text-to-hex
|
||||
|
@ -2201,7 +2200,8 @@ With given ARG, display files in `db/important-document-path’."
|
|||
(add-hook 'shell-mode-hook 'with-editor-export-editor)))
|
||||
|
||||
(use-package db-eshell
|
||||
:commands (eshell-clear-buffer
|
||||
:commands (db/run-or-hide-eshell
|
||||
eshell-clear-buffer
|
||||
eshell/default-prompt-function
|
||||
eshell/gst
|
||||
eshell-insert-history
|
||||
|
|
|
@ -8,16 +8,44 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(require 'subr-x)
|
||||
(require 'seq)
|
||||
(require 'eshell)
|
||||
(require 'em-basic)
|
||||
(require 'em-dirs)
|
||||
(require 'em-hist)
|
||||
(autoload 'magit-status "magit")
|
||||
(autoload 'db/find-window-by-buffer-mode "db-utils")
|
||||
|
||||
|
||||
;; Various
|
||||
|
||||
(defun db/run-or-hide-eshell (arg)
|
||||
"Opens an eshell buffer if not already in one, and otherwise
|
||||
returns to where we have been before."
|
||||
;; idea to split the current window is from
|
||||
;; http://howardism.org/Technical/Emacs/eshell-fun.html
|
||||
(interactive "P")
|
||||
(if (string= "eshell-mode" major-mode)
|
||||
;; bury buffer; reopen with current working directory if arg is given
|
||||
(progn
|
||||
(bury-buffer)
|
||||
(delete-window)
|
||||
(and arg (db/run-or-hide-eshell arg)))
|
||||
(if-let ((eshell-window (db/find-window-by-buffer-mode 'eshell-mode)))
|
||||
(select-window eshell-window)
|
||||
;; open eshell
|
||||
(let ((current-dir (expand-file-name default-directory))
|
||||
(height (/ (window-total-height) 3)))
|
||||
(split-window-vertically (- height))
|
||||
(other-window 1)
|
||||
(eshell 1)
|
||||
(when arg
|
||||
(end-of-line)
|
||||
(eshell-kill-input)
|
||||
(insert (format "cd '%s'" current-dir))
|
||||
(eshell-send-input))))))
|
||||
|
||||
(defun eshell-clear-buffer ()
|
||||
"Clear terminal."
|
||||
(interactive)
|
||||
|
|
|
@ -50,32 +50,6 @@ If already in `*ansi-term*' buffer, bury it."
|
|||
(interactive)
|
||||
(find-file user-init-file))
|
||||
|
||||
(defun db/run-or-hide-eshell (arg)
|
||||
"Opens an eshell buffer if not already in one, and otherwise
|
||||
returns to where we have been before."
|
||||
;; idea to split the current window is from
|
||||
;; http://howardism.org/Technical/Emacs/eshell-fun.html
|
||||
(interactive "P")
|
||||
(if (string= "eshell-mode" major-mode)
|
||||
;; bury buffer; reopen with current working directory if arg is given
|
||||
(progn
|
||||
(bury-buffer)
|
||||
(delete-window)
|
||||
(and arg (db/run-or-hide-eshell arg)))
|
||||
(if-let ((eshell-window (db/find-window-by-buffer-mode 'eshell-mode)))
|
||||
(select-window eshell-window)
|
||||
;; open eshell
|
||||
(let ((current-dir (expand-file-name default-directory))
|
||||
(height (/ (window-total-height) 3)))
|
||||
(split-window-vertically (- height))
|
||||
(other-window 1)
|
||||
(eshell 1)
|
||||
(when arg
|
||||
(end-of-line)
|
||||
(eshell-kill-input)
|
||||
(insert (format "cd '%s'" current-dir))
|
||||
(eshell-send-input))))))
|
||||
|
||||
(defun db/run-or-hide-shell ()
|
||||
"Opens an shell buffer if not already in one, and otherwise
|
||||
returns to where we have been before."
|
||||
|
|
Loading…
Reference in New Issue