Shell/Helm: Replace custom helm-ff-switch-to-shell with upstream.
parent
d29397ef05
commit
adce533dc2
|
@ -1,44 +1,4 @@
|
|||
(defun ambrevar/helm-ff--shell-interactive-buffer-p (buffer)
|
||||
(with-current-buffer buffer
|
||||
(and (eq major-mode 'shell-mode)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(comint-next-prompt 1)
|
||||
(null (eql (point) (point-min)))))))
|
||||
|
||||
(defun ambrevar/helm-ff-switch-to-shell (_candidate)
|
||||
"Like `helm-ff-switch-to-eshell' but for `M-x shell'.
|
||||
|
||||
With a numeric prefix arg switch to numbered shell buffer, if no
|
||||
prefix arg provided and more than one shell buffer exists, provide
|
||||
completions on those buffers. If only one shell buffer exists,
|
||||
switch to this one, if no shell buffer exists or if the numeric
|
||||
prefix arg shell buffer doesn't exists, create it and switch to it."
|
||||
(let ((cd-shell
|
||||
(lambda ()
|
||||
(goto-char (point-max))
|
||||
(comint-delete-input)
|
||||
(insert (format "cd %s"
|
||||
(shell-quote-argument
|
||||
(if (tramp-tramp-file-p helm-ff-default-directory)
|
||||
(tramp-file-name-localname
|
||||
(tramp-dissect-file-name helm-ff-default-directory))
|
||||
helm-ff-default-directory))))
|
||||
(comint-send-input)))
|
||||
(bufs (cl-loop for b in (mapcar 'buffer-name (buffer-list))
|
||||
when (ambrevar/helm-ff--shell-interactive-buffer-p b)
|
||||
collect b)))
|
||||
(helm-aif (and (null helm-current-prefix-arg)
|
||||
(if (cdr bufs)
|
||||
(helm-comp-read "Switch to shell buffer: " bufs
|
||||
:must-match t)
|
||||
(car bufs)))
|
||||
(switch-to-buffer it)
|
||||
(shell))
|
||||
(funcall cd-shell)))
|
||||
|
||||
(advice-add 'helm-ff-switch-to-eshell :override 'ambrevar/helm-ff-switch-to-shell)
|
||||
;; TODO: Above code can be removed with Helm 3.6.3.
|
||||
(setq helm-ff-preferred-shell-mode 'shell-mode)
|
||||
|
||||
(defun ambrevar/shell-setup ()
|
||||
(set (make-variable-buffer-local 'comint-input-history-ignore)
|
||||
|
|
Loading…
Reference in New Issue