-
-
Notifications
You must be signed in to change notification settings - Fork 312
Description
ls on macOS does not support long-format options(such as --dired), as a result, the Dired configuration causes an error message like this:
Listing directory failed but 'access files' worked
Delete --group-directories-first argument can help get rid of this error, but a GNU-based ls which is exposed as gls by the coreutils formula can solve this problem. Here's my solution to this:
- install
homebrew - run
brew install coreutilsto installgls - add some judgements to the
Diredconfiguration:
(use-package dired
:ensure nil
:commands (dired dired-jump)
:bind (("C-x C-j" . dired-jump))
:config
(when (string= system-type "darwin")
(let ((gls (executable-find "gls")))
(when gls
(setq dired-use-ls-dired t
insert-directory-program gls
dired-listing-switches "-aBhl --group-directories-first")))))
Note that GUI applications and applications launched via shell see different environment variables on macOS, so executable -find function may not be able to find gls if you start Emacs by clicking the app icon or from spotlight. Thankfully a package called exec-path-from-shell can help. Here is the GitHub homepage for this package:
https://github.com/purcell/exec-path-from-shell
More info:
https://stackoverflow.com/questions/8606954/path-and-exec-path-set-but-emacs-does-not-find-executable