branch: master
commit 802c9dacb5379b8cec8d6751db44ecdf345dc61d
Author: joe di castro <[email protected]>
Commit: Oleh Krehel <[email protected]>
counsel.el: Add counsel-command-history
Fixes #826
---
counsel.el | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/counsel.el b/counsel.el
index cc7b65d..6290ba7 100644
--- a/counsel.el
+++ b/counsel.el
@@ -3036,6 +3036,31 @@ candidate."
:caller 'counsel-faces
:sort t)))
+;;** `counsel-command-history'
+(defun counsel-command-history-action-eval (cmd)
+ "Eval the command CMD."
+ (eval (read cmd)))
+
+(defun counsel-command-history-action-edit-and-eval (cmd)
+ "Edit and eval the command CMD."
+ (edit-and-eval-command "Eval: " (read cmd)))
+
+(ivy-set-actions
+ 'counsel-command-history
+ '(("r" counsel-command-history-action-eval "eval command")
+ ("e" counsel-command-history-action-edit-and-eval "edit and eval
command")))
+
+(defun counsel-command-history ()
+ "Show the history of commands."
+ (interactive)
+ (ivy-read "%d Command: "
+ (mapcar (lambda (x)
+ (format "%s" x))
+ command-history)
+ :require-match t
+ :action #'counsel-command-history-action-eval
+ :caller 'counsel-command-history))
+
;** `counsel-mode'
(defvar counsel-mode-map
(let ((map (make-sparse-keymap)))