Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with Dired configuration on macOS #80

Open
ricky9w opened this issue Feb 8, 2022 · 0 comments
Open

Problems with Dired configuration on macOS #80

ricky9w opened this issue Feb 8, 2022 · 0 comments

Comments

@ricky9w
Copy link

ricky9w commented Feb 8, 2022

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:

  1. install homebrew
  2. run brew install coreutils to install gls
  3. add some judgements to the Dired configuration:
(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

@ricky9w ricky9w changed the title Dired listing switches on macOS Problems with Dired configuration on macOS Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant