在使用 counsel 进行搜索时显示具体的命令

在使用 counsel-rg 或者 counsel-ag 的时候, counsel 内部常常将正则表达式进行转义, 用下面的方法可以显示具体的搜索命令是什么.

(defun counsel-before-counsel--async-command (cmd &rest _)
  (unless (stringp cmd)
    (setq cmd (string-join cmd " ")))
  (lv-message "Command: (@%s) %s"
              (propertize default-directory 'face font-lock-constant-face)
              (propertize cmd 'face font-lock-doc-face)))

(advice-add 'counsel--async-command :before
            #'counsel-before-counsel--async-command)

1 个赞