Skip to content
Icy-Thought edited this page Feb 14, 2024 · 4 revisions

Pretty-Hydra

On this page, you will find essential code-blocks and a package list to assist you in establishing your unique activities Hydra menu. The purpose of the Hydra is to enable users to swiftly interact with various helpful 'activity' features by executing designated commands using assigned keybindings.

Preview

Workspace 2024-02-04 22:19:35

Requirements

Implementation

Note

Credits of the snippet provided below belongs to the original author whom I cannot seem to recall.

Once you have installed the required packages, proceed by adding the cl-defun function provided below to help your pretty-hydra menu generate a pretty title (+icon) for your hydra menus.

(cl-defun pretty-hydra-title (title &optional icon-type icon-name
                                      &key face height v-adjust)
    "Add an icon to our pretty-hydra title."
    (let ((face (or face `(:inherit hydra-face-pink :height 1.2 :slant italic)))
          (height (or height 1.2))
          (v-adjust (or v-adjust 0.0)))
      (concat
       (when (and (display-graphic-p) icon-type icon-name)
         (let ((f (intern (format "nerd-icons-%s" icon-type))))
           (when (fboundp f)
             (concat
              (apply f (list icon-name :face face :height height :v-adjust v-adjust))
              "  "))))
       (propertize title 'face face))))

After adding the pretty-hydra-title snippet to your Emacs configuration, paste the following Pretty-Hydra example into your config file and customize it according to your preferences.

(with-eval-after-load 'pretty-hydra
  (pretty-hydra-define activities-hydra
    (:title (pretty-hydra-title "──「 Utilities: Activities 」──" 'mdicon "nf-md-file_tree")
            :color teal :quit-key "q")
    ("Main"
     (("l"     activities-list     "List")
      ("<RET>" activities-switch   "Switch"))
     "Working"
     (("n"     activities-new      "Create")
      ("k"     activities-kill     "Kill")
      ("u"     activities-revert   "Revert")
      ("w"     activities-save-all "Save All"))
     "Breaktime"
     (("s"     activities-suspend  "Suspend")
      ("r"     activities-resume   "Resume")
      ("d"     activities-discard  "Discard")))))
Clone this wiki locally