Revise term/vterm/eshell commands & keybinds
The semantics of SPC o t and SPC o T (or SPC o e and SPC o E in eshell's case) have been reversed. The lowercase keybind toggles the popup (and the prefix arg forciby recreates the popup), and the uppercase keybind switches to that terminal in the current buffer (whose prefix arg will open the terminal in default-directory, rather than the project root). - +{term,vterm,eshell}/open have been replaced with +X/here commands and are bound to SPC o T (and SPC o E in eshell's case). - +{term,vterm,eshell}/popup* have been replaced with +x/toggle commands and are bound to SPC o t (and SPC o e in eshell's case). The "toggle" behavior will do as the name implies, except will select the popup if it is visible but unfocused.
This commit is contained in:
parent
750d7629e1
commit
4fec3eb698
8 changed files with 150 additions and 91 deletions
|
@ -78,48 +78,79 @@
|
|||
;; Commands
|
||||
|
||||
;;;###autoload
|
||||
(defun +eshell/open (arg &optional command)
|
||||
(defun +eshell/toggle (arg &optional command)
|
||||
"Toggle eshell popup window at project's root.
|
||||
|
||||
Changes the PWD to the PWD of the buffer this command is executed from a new
|
||||
project (or if prefix ARG was present)."
|
||||
(interactive "P")
|
||||
(let ((eshell-buffer (get-buffer-create "*doom:eshell-popup*"))
|
||||
(target-project (or (doom-project-root) default-directory))
|
||||
confirm-kill-processes
|
||||
current-prefix-arg)
|
||||
(when arg
|
||||
(when-let (win (get-buffer-window eshell-buffer))
|
||||
(delete-window win))
|
||||
(when (buffer-live-p eshell-buffer)
|
||||
(kill-buffer eshell-buffer)))
|
||||
(if-let (win (get-buffer-window eshell-buffer))
|
||||
(if (eq (selected-window) win)
|
||||
(let (confirm-kill-processes)
|
||||
(delete-window win)
|
||||
(ignore-errors (kill-buffer eshell-buffer)))
|
||||
(select-window win))
|
||||
(with-current-buffer (pop-to-buffer eshell-buffer)
|
||||
(if (eq major-mode 'eshell-mode)
|
||||
(run-hooks 'eshell-mode-hook)
|
||||
(eshell-mode))
|
||||
(let ((old-project (doom-project-root)))
|
||||
(when (and old-project
|
||||
target-project
|
||||
(not (file-equal-p old-project target-project)))
|
||||
(setq default-directory target-project)
|
||||
(with-silent-modifications
|
||||
(goto-char (point-max))
|
||||
(when (re-search-backward eshell-prompt-regexp)
|
||||
(delete-region (match-end 0) (point-max)))
|
||||
(eshell-send-input))))
|
||||
(when command
|
||||
(+eshell-run-command command buf))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +eshell/here (arg &optional command)
|
||||
"Open eshell in the current buffer."
|
||||
(interactive "P")
|
||||
(when (eq major-mode 'eshell-mode)
|
||||
(user-error "Already in an eshell buffer"))
|
||||
(let* ((default-directory (or (if arg default-directory (doom-project-root))
|
||||
default-directory))
|
||||
(let* ((default-directory
|
||||
(if arg
|
||||
default-directory
|
||||
(or (doom-project-root) default-directory)))
|
||||
(buf (+eshell--unused-buffer)))
|
||||
(with-current-buffer (switch-to-buffer buf)
|
||||
(if (eq major-mode 'eshell-mode)
|
||||
(run-hooks 'eshell-mode-hook)
|
||||
(eshell-mode))
|
||||
(if command (+eshell-run-command command buf)))
|
||||
(when command
|
||||
(+eshell-run-command command buf)))
|
||||
buf))
|
||||
|
||||
;;;###autoload
|
||||
(defun +eshell/open-popup (arg &optional command)
|
||||
"Open eshell in a popup window."
|
||||
(interactive "P")
|
||||
(let* ((default-directory (or (if arg default-directory (doom-project-root))
|
||||
default-directory))
|
||||
(buf (+eshell--unused-buffer)))
|
||||
(with-current-buffer (pop-to-buffer buf)
|
||||
(if (eq major-mode 'eshell-mode)
|
||||
(run-hooks 'eshell-mode-hook)
|
||||
(eshell-mode))
|
||||
(if command (+eshell-run-command command buf)))
|
||||
buf))
|
||||
(defun +eshell/frame (arg &optional command)
|
||||
"Open a frame dedicated to eshell.
|
||||
|
||||
;;;###autoload
|
||||
(defun +eshell/open-fullscreen (arg &optional command)
|
||||
"Open eshell in a separate workspace. Requires the (:ui workspaces)
|
||||
module to be loaded."
|
||||
Once the eshell process is killed, the previous frame layout is restored."
|
||||
(interactive "P")
|
||||
(let ((default-directory (or (if arg default-directory (doom-project-root))
|
||||
default-directory))
|
||||
(buf (+eshell--unused-buffer 'new)))
|
||||
(set-frame-parameter nil 'saved-wconf (current-window-configuration))
|
||||
(unless (frame-parameter nil 'saved-wconf)
|
||||
(set-frame-parameter nil 'saved-wconf (current-window-configuration)))
|
||||
(delete-other-windows)
|
||||
(with-current-buffer (switch-to-buffer buf)
|
||||
(eshell-mode)
|
||||
(if command (+eshell-run-command command buf)))
|
||||
(when command
|
||||
(+eshell-run-command command buf)))
|
||||
buf))
|
||||
|
||||
|
||||
|
@ -267,7 +298,7 @@ delete."
|
|||
(cond ((and (one-window-p t)
|
||||
(window-configuration-p (frame-parameter nil 'saved-wconf)))
|
||||
(set-window-configuration (frame-parameter nil 'saved-wconf))
|
||||
(set-frame-parameter win 'saved-wconf nil))
|
||||
(set-frame-parameter nil 'saved-wconf nil))
|
||||
((one-window-p)
|
||||
(let ((prev (save-window-excursion (previous-buffer))))
|
||||
(unless (and prev (doom-real-buffer-p prev))
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
;;; term/eshell/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
;; see:
|
||||
;; + `+eshell/open': open in current buffer
|
||||
;; + `+eshell/open-popup': open in a popup
|
||||
;; + `+eshell/open-fullscreen': open eshell fullscreen (will restore window
|
||||
;; config when quitting the last eshell buffer)
|
||||
;; + `+eshell/here': open eshell in the current window
|
||||
;; + `+eshell/toggle': toggles an eshell popup
|
||||
;; + `+eshell/frame': converts the current frame into an eshell-dedicated
|
||||
;; frame. Once the last eshell process is killed, the old frame configuration
|
||||
;; is restored.
|
||||
|
||||
(defvar +eshell-config-dir
|
||||
(expand-file-name "eshell/" doom-private-dir)
|
||||
|
@ -32,7 +33,7 @@ like fasd and bd. Note that you may overwrite these in your
|
|||
`eshell-aliases-file'. This is here to provide an alternative, elisp-centric way
|
||||
to define your aliases.
|
||||
|
||||
You should use `det-eshell-alias!' to change this.")
|
||||
You should use `set-eshell-alias!' to change this.")
|
||||
|
||||
;;
|
||||
(defvar eshell-directory-name (concat doom-etc-dir "eshell"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue