Use Ivy completion with Smex command matching
NOTE: This package is redundant, given counsel-M-x, but I'm leaving it here anyway.
Smex has really nice handling
of command histories, favouring commands which have been executed most
frequently in the past. This package provides an
Ivy interface to those internals
via the ivy-smex command, which is meant as a replacement for
execute-extended-command or smex:
This package was inspired by - and based in part on - helm-smex.
Installation
Manual
Ensure ivy-smex.el is in a directory on your load-path, and
add the following to your ~/.emacs or ~/.emacs.d/init.el:
(require 'ivy-smex)
(global-set-key (kbd "M-x") 'ivy-smex)MELPA
If you're an Emacs 24 user or you have a recent version of
package.el you can install ivy-smex from the
MELPA repository. The version of
ivy-smex there will always be up-to-date.
To make ivy-smex your default M-x command, add the following to
your ~/.emacs or ~/.emacs.d/init.el:
(global-set-key (kbd "M-x") 'ivy-smex)About
Author: Steve Purcell
Homepage: https://github.com/purcell/ivy-smex
This little library was extracted from the author's full Emacs configuration, which readers might find of interest.

