branch: externals/ivy-hydra
commit 7d94e675c9717bc3726e50af25beeed4c2719525
Author: Troy Hinckley <[email protected]>
Commit: Oleh Krehel <[email protected]>
Use the current prompt for shell history initial input
Fixes #2400
---
counsel.el | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/counsel.el b/counsel.el
index 429a91e..3d964f6 100644
--- a/counsel.el
+++ b/counsel.el
@@ -4432,12 +4432,20 @@ An extra action allows to switch to the process buffer."
;;** `counsel-esh-history'
(defun counsel--browse-history (ring)
"Use Ivy to navigate through RING."
- (setq ivy-completion-beg (point))
- (setq ivy-completion-end (point))
- (ivy-read "History: " (ivy-history-contents ring)
- :keymap ivy-reverse-i-search-map
- :action #'ivy-completion-in-region-action
- :caller 'counsel-shell-history))
+ (let* ((proc (get-buffer-process (current-buffer)))
+ (end (point))
+ (beg (if proc
+ (min (process-mark proc) end)
+ end))
+ (input (when (< beg end)
+ (concat "^" (buffer-substring beg end)))))
+ (setq ivy-completion-beg beg)
+ (setq ivy-completion-end end)
+ (ivy-read "History: " (ivy-history-contents ring)
+ :keymap ivy-reverse-i-search-map
+ :initial-input input
+ :action #'ivy-completion-in-region-action
+ :caller 'counsel-shell-history)))
(defvar eshell-history-ring)