pudentia · 2022-09-01 16:37
I have been experimenting with `tab-bar-mode` which I have found very useful for arranging my workspaces. I frequently open a directory in dired and like to work from that. I can open files in `tab-bar mode` using `C-x t C-f` but I would like simply to be able to simply `<ret>` on a file in `dired` and have it *optionally* open that file in a tab. I say *optionally* because I would not like to do this with all my files, but only when I choose to create a workspace of tabs.
ALLCAPSNOBRAKES · 2022-09-01 17:56
This function will open the file in a new tab when given the prefix argument (`C-u`), but behave normally otherwise:
(defun dired-find-file-maybe-other-tab (&optional prefix)
"Open the file at point, in another tab if given PREFIX."
(interactive "P")
(if prefix
(find-file-other-tab (dired-get-file-for-visit))
(dired-find-file)))
You can bind it to `<ret>` in `dired-mode` like this:
(define-key dired-mode-map (kbd "RET") #'dired-find-file-maybe-other-tab)
pudentia · 2022-09-01 18:00
I will test it in the morning when at my PC. Many thanks for replying.
_viz_ · 2022-09-02 00:40
Use the C-x t t prefix when you want to open a file in another tab.