Eshell: Add helm-eshell-mini
parent
553d62e7a3
commit
fda4f4d498
|
@ -257,6 +257,56 @@ This should be faster then `seq-uniq'."
|
|||
;; (add-hook 'eshell-mode-hook 'ambrevar/fix-local-epa-file-encrypt-to)
|
||||
|
||||
;;; Spawning
|
||||
(defvar helm-eshell-buffers-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(set-keymap-parent map helm-map)
|
||||
(define-key map (kbd "C-c o") 'helm-buffer-switch-other-window)
|
||||
(define-key map (kbd "C-c C-o") 'helm-buffer-switch-other-frame)
|
||||
(define-key map (kbd "M-D") 'helm-buffer-run-kill-buffers)
|
||||
map)
|
||||
"Keymap for browser source in Helm.")
|
||||
|
||||
(defun ambrevar/helm-buffer-transformer (buffers)
|
||||
(mapcar #'buffer-name buffers))
|
||||
|
||||
(defun ambrevar/helm-eshell-buffers ()
|
||||
"Yet another smart buffer switcher with `helm'."
|
||||
(interactive)
|
||||
(helm-build-sync-source "Eshell buffers"
|
||||
:candidates (seq-filter (lambda (b) (with-current-buffer b
|
||||
(derived-mode-p 'eshell-mode)))
|
||||
(buffer-list))
|
||||
:candidate-transformer #'ambrevar/helm-buffer-transformer
|
||||
;; :filtered-candidate-transformer #'helm-highlight-buffers
|
||||
:action `(("Switch to buffer(s)" . helm-buffer-switch-buffers)
|
||||
(,(substitute-command-keys "Switch to buffer(s) in other window \\<helm-eshell-buffers-map>`\\[helm-buffer-switch-other-window]'")
|
||||
. helm-buffer-switch-buffers-other-window)
|
||||
(,(substitute-command-keys "Switch to buffer in other frame \\<helm-eshell-buffers-map>`\\[helm-buffer-switch-other-frame]'")
|
||||
. switch-to-buffer-other-frame)
|
||||
(,(substitute-command-keys "Kill buffer(s) \\<helm-eshell-buffers-map>`\\[helm-buffer-run-kill-buffers]'")
|
||||
. helm-kill-marked-buffers))
|
||||
:keymap helm-eshell-buffers-map
|
||||
:persistent-action 'helm-buffers-list-persistent-action))
|
||||
(add-to-list 'helm-source-names-using-follow "Eshell buffers")
|
||||
|
||||
(defun ambrevar/helm-eshell-new (name)
|
||||
"Fetch URL and render the page in a new buffer.
|
||||
If the input doesn't look like an URL or a domain name, the
|
||||
word(s) will be searched for via `eww-search-prefix'."
|
||||
(eshell 'new)
|
||||
(rename-buffer (format "*eshell<%s>*" name) 'unique))
|
||||
|
||||
(defvar ambrevar/helm-eshell-new
|
||||
(helm-build-dummy-source "Open new Eshell"
|
||||
:action (helm-make-actions "Open new Eshell" 'ambrevar/helm-eshell-new-buffer)))
|
||||
|
||||
(defun ambrevar/helm-eshell-mini ()
|
||||
"Helm for Eshell buffers."
|
||||
(interactive)
|
||||
(helm :sources (list (ambrevar/helm-eshell-buffers)
|
||||
'ambrevar/helm-eshell-new)
|
||||
:buffer "*helm-eshell-mini*"))
|
||||
|
||||
(defun ambrevar/eshell-or-new-session (&optional arg)
|
||||
"Create an interactive Eshell buffer.
|
||||
Switch to last Eshell session if any.
|
||||
|
@ -264,7 +314,8 @@ Otherwise create a new one and switch to it.
|
|||
See `eshell' for the numeric prefix ARG."
|
||||
(interactive "P")
|
||||
(if (or arg (eq major-mode 'eshell-mode))
|
||||
(eshell (or arg t))
|
||||
(ambrevar/helm-eshell-mini)
|
||||
;; (eshell (or arg t))
|
||||
(let ((last (buffer-list)))
|
||||
(while (and last
|
||||
(not (with-current-buffer (car last)
|
||||
|
|
Loading…
Reference in New Issue