tweak(macos): use full path for open by neuhalje · Pull Request #8433 · doomemacs/doomemacs · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

tweak(macos): use full path for open #8433

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

neuhalje
Copy link

@neuhalje neuhalje commented Jul 2, 2025

Use the full path for the MacOS "open" command.

Using plain "open" will conflict with nushell's "open" command. Use the full path for open to make it working.

Use the full path for the MacOS "open" command.

Using plain "open" will conflict with nushell's "open" command. Use the full path for open to make it working.
@hlissner
Copy link
Member

hlissner commented Jul 2, 2025

I'd rather avoid full paths where I can (so users can still shim or replace open at the system level). Might be better to swap out shell-command for doom-call-process instead. Could you drop this advice into $DOOMDIR/config.el and see if it solves this for you?

(defadvice! fixed-+macos-open-with (&optional app-name path)
  :override #'+macos-open-with
  (let* ((path (expand-file-name
                (replace-regexp-in-string
                 "'" "\\'"
                 (or path (if (derived-mode-p 'dired-mode)
                              (dired-get-file-for-visit)
                            (buffer-file-name)))
                 nil t)))
         (args (cons "open"
                     (append (if app-name (list "-a" app-name))
                             (list path)))))
    (message "Running: %S" args)
    (apply #'doom-call-process args)))

@hlissner hlissner added is:bug Something isn't working as intended module:os/macos Pertains to Doom's :os macos module labels Jul 2, 2025
@neuhalje
Copy link
Author

neuhalje commented Jul 2, 2025

That works

Copy link
Member

@hlissner hlissner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then in that case, please make this change to +macos-open-with:

                               (dired-get-file-for-visit)
                             (buffer-file-name)))
                  nil t)))
-         (command (format "open %s"
-                          (if app-name
-                              (format "-a %s '%s'" (shell-quote-argument app-name) path)
-                            (format "'%s'" path)))))
-    (message "Running: %s" command)
-    (shell-command command)))
+         (args (cons "open"
+                     (append (if app-name (list "-a" app-name))
+                             (list path)))))
+    (message "Running: %S" args)
+    (apply #'doom-call-process args)))

@hlissner hlissner added this to the modules v25.07 milestone Jul 2, 2025
@jdelStrother
Copy link

jdelStrother commented Jul 3, 2025

@neuhalje presumably this is because shell-file-name points to nu? Maybe instead you might set it to a more 'normal' shell like bash - I remember I had to do this a while back when I had SHELL=fish:

(setq shell-file-name (executable-find "bash"))
(let ((fishpath (executable-find "fish")))
  (when fishpath
    (setq explicit-shell-file-name fishpath
          vterm-shell fishpath)))

Otherwise I ran into a lot of problems with emacs modules that expected shell-command to work with regular bashisms.

hlissner's suggestion looks good though - I don't think there's any need to use a shell for macos-open-with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is:bug Something isn't working as intended module:os/macos Pertains to Doom's :os macos module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.