;; -*- coding: utf-8; lexical-binding: t; -*- ;; before 2022-08-19 (defun xah-show-in-desktop () "Show current file in desktop. (Mac Finder, File Explorer, Linux file manager) This command can be called when in a file buffer or in `dired'. URL `http://xahlee.info/emacs/emacs/emacs_dired_open_file_in_ext_apps.html' Version: 2020-11-20 2022-04-20" (interactive) (let (($path (if (eq major-mode 'dired-mode) (if (eq nil (dired-get-marked-files)) default-directory (car (dired-get-marked-files))) (if (buffer-file-name) (buffer-file-name) default-directory)))) (cond ((string-equal system-type "windows-nt") (shell-command (format "PowerShell -Command invoke-item '%s'" (expand-file-name default-directory)))) ((string-equal system-type "darwin") (shell-command (concat "open -R " (shell-quote-argument $path)))) ((string-equal system-type "gnu/linux") (let ((process-connection-type nil) ($openFileProgram (if (file-exists-p "/usr/bin/gvfs-open") "/usr/bin/gvfs-open" "/usr/bin/xdg-open"))) (start-process "" nil $openFileProgram (shell-quote-argument $path))) ;; (shell-command "xdg-open .") ;; 2013-02-10 this sometimes froze emacs till the folder is closed. eg with nautilus )))) ;; after 2022-08-19 (defun xah-show-in-desktop () "Show current file in desktop. (Mac Finder, File Explorer, Linux file manager) This command can be called when in a file buffer or in `dired'. URL `http://xahlee.info/emacs/emacs/emacs_dired_open_file_in_ext_apps.html' Version: 2020-11-20 2022-04-20" (interactive) (let (($path (if (eq major-mode 'dired-mode) (if (eq nil (dired-get-marked-files)) default-directory (car (dired-get-marked-files))) (if (buffer-file-name) (buffer-file-name) default-directory)))) (cond ((string-equal system-type "windows-nt") (shell-command (format "PowerShell -Command invoke-item '%s'" (expand-file-name default-directory)))) ((string-equal system-type "darwin") (shell-command (concat "open -R " (shell-quote-argument $path)))) ((string-equal system-type "gnu/linux") (call-process shell-file-name nil nil nil shell-command-switch (format "%s %s" "xdg-open" (file-name-directory $path))) ;; (shell-command "xdg-open .") ;; 2013-02-10 this sometimes froze emacs till the folder is closed. eg with nautilus ))))