A number of applications under Linux provide a “Browse Files” button that is intended to pull up a file manager in a specific directory. While this is convenient for most users, some might want a little more flexibility, so let’s hook up a terminal emulator to that button instead of a file manager.
First, we need a command that starts a terminal emulator in a specific directory, in my case this will be
foot -D <path to directory>
which will start foot in the specified <path to directory>
.
As this button is implemented leveraging the XDG MIME Applications specification, we now need to define a new desktop entry, let’s call it TermFM.desktop
, which we place under either ~/.local/share/applications
or /usr/local/share/applications
, depending on preference.
The file using a foot terminal should read
[Desktop Entry]
Type=Application
Name=TermFM
Exec=foot -D %U
MimeType=inode/directory;
where %U
will be the placeholder for the path that is handed over by the calling application.
The MimeType
line is optional, but given that the above terminal command only works for directories anyways, it doesn’t hurt to constrain this desktop file to this file type only.
Afterwards, we need to configure this as the default applications for the file type inode/directory
, which we do by adding
inode/directory=TermFM.desktop
to the [Default Applications]
section in ~/.config/mimeapps.list
.
Should this file not yet exist, you can create it to contain
[Default Applications]
inode/directory=TermFM.desktop
Once that is done, you should from now on get your terminal at the according location when you click “Browse Files” in an application supporting this.