Trying here to set color for executable files, as it is for ls command!

How can I do that?

I've already managed to set color for certains file extensions, using Diredful package, but couldn't do it according to it's mode!


Define "executable file" and a file's "mode".

If you mean something that ls recognizes as executable and flags as such, with an asterisk (*), when you use ls switch F, then Dired+ highlights that. It uses face `` for the asterisk.

;; For this to show up, you need `F' among the options in `dired-listing-switches'.
;; For example, I use "-alF" for `dired-listing-switches'.
(defface diredp-executable-tag
    '((t (:foreground "Red")))
  "Face used for executable tag (*) on file names in Dired buffers."
  :group 'Dired-Plus :group 'font-lock-highlighting-faces)
  • Would you know how I could install Dired+? As of Emacs 26 it doens't seems to be available in MELPA Stable! Aug 8 '19 at 23:51
  • See Dired+. The library is here: dired+.el. Put it in a directory that is in your load-path (user option), then put (require 'dired) in your init file.
    – Drew
    Aug 9 '19 at 0:18
  • That just worked swiftly! But my problem I've solved with diredful-add, then named Type Name, which was Executables. In pattern I entered $*, to match those binaries with * at the end! And in Pattern Type just selected the last option, which was "Regexp on whole line (starting from the first permission column) including file name." So that way now I see the executable files highlighted in colors in Dired mode itself, and not only in Shell mode! Aug 9 '19 at 1:01

For a non-dired-plus version, I use this code to highlight executable files in dired-mode by using the face helm-ff-executable (it can be changed to any other face up to preference):

   (list dired-re-exe
         '(".+" (dired-move-to-filename) nil (0 'helm-ff-executable)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.