I use Emacs 26.3 on Ubuntu 20.04 and I often need to manipulate org files with Ubuntu file manager. It would save me a lot of time if I could open directories from emacs file links. For example, I would like to be able to open folder PRISM through the following link : [[./References/Deliverables/PRISM/proposal.org][PRSM Proposal]].
I don't know much about Ubuntu at the desktop level, but on my Gnome desktop, I can open a directory in the file manager from the command line, using the command
xdg-open /path/to/directory. I assume there is something similar (or perhaps identical) to
xdg-open on the Ubuntu desktop.
If so, all you have to do is write a function that parses the link at point, selects the directory part of the path (which may be the whole path, or it may be a prefix of the path, as in your example) and then calls
xdg-open (or whatever the Ubuntu equivalent is) with that path as argument. Then you bind the function to a key and off you go.
Here's a function that looks at the link at point and calls
the directory part of the path of the link.
#+begin_src emacs-lisp (defun ndk/desktop-open-link-at-point() (interactive) (let* ((context (org-element-lineage (org-element-context) '(link) t)) (type (org-element-type context)) (path (org-element-property :path context)) (dirpath (if (file-directory-p path) path (file-name-directory path)))) (shell-command (format "xdg-open %s" dirpath) nil nil))) #+end_src
For convenience, bind the function to the key
<M-S-f12> (i.e. Meta-Shift-FunctionKey12) or some other undefined key in your keymaps:
#+begin_src emacs-lisp (define-key global-map (kbd "<M-S-f12>") #'ndk/desktop-open-link-at-point) #+end_src