diff options
author | Crazazy | 2023-12-01 18:11:38 +0100 |
---|---|---|
committer | Crazazy | 2023-12-01 18:11:38 +0100 |
commit | 3751ccd3c9cd4656e83de70111e4170772a0e1a6 (patch) | |
tree | a88d67053e3a1f6de2b132d00e7cc47789e4c40c /emenu.el |
Initial commit
Diffstat (limited to 'emenu.el')
-rw-r--r-- | emenu.el | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/emenu.el b/emenu.el new file mode 100644 index 0000000..99adc1c --- /dev/null +++ b/emenu.el @@ -0,0 +1,30 @@ +(defun all-commands () + "does a completing read of all the programs accessible to you in $PATH" + (let ((ls-output (mapcan (lambda (path) + (when (file-readable-p path) + (cl-remove-if (lambda (file) + (let ((fullpath (concat path "/" file))) + (or (file-directory-p fullpath) + (not (file-executable-p fullpath))))) + (directory-files path nil directory-files-no-dot-files-regexp nil)))) + (split-string (getenv "PATH") ":" t))) + (alias-output (split-string (shell-command-to-string "alias -p | sed -E 's/^alias ([^=]*)=.*$/\\1/'") "\n"))) + (append ls-output alias-output))) + +(defun emenu (&optional command-list) + "A dmenu-inspired application launcher using a separate emacs frame" + (interactive) + (with-selected-frame (make-frame '((name . "emenu") + (minibuffer . only) + (width . 151) + (height . 1))) + (unwind-protect + (progn + (call-process + (ido-completing-read "Command: " (or + command-list + (all-commands))) + nil + 0) + (keyboard-quit)) + (delete-frame)))) |