Skip to content

help with counsel-shell-command #689

Description

@njdan5691

Hi,

I use M-: (shell-command) often, and have turned on the history, I would love to have a counsel interface instead of the default behavior. I'm pretty new to elisp but this snippet was my first attempt
at it, using counsel-describe-function as a start. Well obviously this did not work. Would someone be kind enough to help.

Thanks in advance

(defun counsel-shell-command ()
  "Forward to `shell-command'."
  (interactive)
  (ivy-read "Shell Command: "
            (let (cands)
              (mapatoms
               (lambda (x)
                 (when (fboundp x)
                   (push (symbol-name x) cands))))
              cands)
            :keymap counsel-ag-map
            :history 'counsel-shell-command-symbol-history
            :require-match t
            :sort t
            :action (lambda (x)
                      (shell-command
                       (intern x)))
            :caller 'counsel-shell-command))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions