HOW TO: Quickly "Extract Here" archives without opening them or using the right-click menu - Like in the Finder on macOS

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
RedBearAK
Level 1
Level 1
Posts: 36
Joined: Wed Aug 19, 2020 3:03 am

HOW TO: Quickly "Extract Here" archives without opening them or using the right-click menu - Like in the Finder on macOS

Post by RedBearAK »

EDIT:

tl;dr version for those who don't understand how easy it is to extract archives on macOS:

Linux: Double-click or hit Enter on selected archive file: Opens in archive utility. DOES NOT EXTRACT.
Finder: Double-click or hit Enter on selected archive file: Immediately extracts in current folder.

The entire point of this tutorial is that I absolutely DO NOT want to have to constantly access the right-click context menu with the mouse (trackpad) to get to the "Extract Here" function. And yes, I know exactly where it is, where it has always been in Linux and Windows. I also know why it doesn't need to exist in the Finder context menu. Because the Mac archivers just automatically extract archives without displaying a window. By default.

In other words, I don't like using mouse-based context menus for things I'm doing constantly in a file browser, like making new folders, renaming files, and extracting archives into the current folder. It's inefficient. With the solution in this tutorial, I don't have to (this is for quick archive extraction, I have Kinto.sh that fixes the other keyboard shortcuts for renaming, duplicating, and creating new folders and stuff).

EDIT ENDED.
.
..
...

PROBLEM DISCUSSION:

I googled around and couldn't find a good answer to this problem, so I'm going to write up the solution(s) I found here. I'm going to document this solution thoroughly, for my own benefit if nothing else. There's a lot of wordy talkie-talkie here describing what the issue is and why I wanted to find the solution, and trying to explain to an inexperienced user exactly how to implement it.

Scroll down below to "THE SOLUTION" if you don't care about the discussion part.

The solution presented here, as far as I know, is relevant for many desktop environments (e.g., Cinnamon, MATE, Xfce, probably others) and different file browsers/managers (e.g., Nemo, Nautilus, Thunar, probably others). I think it depends on whether your chosen file browser conforms to current Linux desktop standards.

I come at this from the perspective of living mostly in macOS for a couple of decades now. It is a very "smooth" world to live in, for most everyday desktop activities. In the Finder on macOS, by default any archive file types (such as zip files) that you try to "open" are just instantly extracted into the current folder without actually "opening" in an application window and going through extra steps. This is true for the built-in simple Apple "Archive Utility" application, and also for the very popular and more capable third-party utility called "The Unarchiver", which I have always installed on a new Mac to increase the number of different archive formats that I can easily extract. You can set The Unarchiver to behave differently, but by default it does "extract here, and create a folder if the archive contains more than one file". You never actually see the applications, they just extract the archives and maybe open the resulting folder for you, automatically. Which is also handy at times, but is configurable in The Unarchiver.

In contrast, in Linux, the default behavior everywhere in file browsers seems to be to "open" archive files in the associated application, the same way you would "open" many other types of files or documents. The problem with this is that I can literally count on one hand the number of times over the past two decades I've actually cared to "open" an archive in the archiving utility application rather than simply extract its contents immediately. And when I want to extract an archive file, I put it where I want the contents extracted, which 99% of the time is right where I downloaded it, in the Downloads folder. So I don't want to be asked where to put the extracted files. Every. Single. Time.

To me, this business of "opening" archives in an application, which if I then click the "Extract" button asks me where I want to extract the files, is a complete waste of my time. This forces me to always right-click and scroll down to "Extract Here" in the file browser context menu in order to do what was automatic and easy in Apple's Finder. From what I remember Windows has always behaved this way also, so before I got familiar with macOS, I thought this was normal. But since I got used to how easy this is in the Finder, I find this default behavior very annoying. Annoying enough to write this lengthy diatribe and teach myself how to fix the problem.

One reason this is so annoying is because I like to use the keyboard for most actions in the file browser, yet the "Extract Here" option is only available via the right-click context menu, and as far as I can tell it is not available to have a keyboard shortcut assigned. Which in any case would be a solution specific to each individual file browser application, so kind of useless. Even if there is a key on the keyboard dedicated to a right-click (a lot of laptops have one, mine does), it's far more cumbersome to open the context menu and scroll down than it is to just select the file and hit the Enter key to immediately extract. (Or in my case Alt+Down, because I'm using Kinto.sh to make my keyboard shortcuts behave like macOS.)

Looking around for a simple solution to this, I came up pretty empty. This is, unfortunately, typical of the difference in the mindset of the average Linux user versus the average Mac user. Mac users want things to be simple and automatic, because Apple and Mac software developers go to great lengths to make things simple and automatic, so we get used to it. It's like spending every day in a soft, comfortable bean bag chair rather than sitting at a desk in a slightly uncomfortable office chair that squeaks every now and then. Linux users are used to having more manual "control" over things. Even in cases like this when it's really unnecessary and redundant. So apparently nobody in Linux-land thinks this is a thing worthy of improving.

Well, I do, and I finally figured out a couple of good ways to make this extraction process simple and automatic. After failing several times.

On my Mint 20.1 system I happen to have two different applications that call themselves the very generic name of "Archive Manager". Only one of these applications is even honest about its true name when you go to Help > About. One is "Engrampa" and the other is actually called "File Roller". They seem to be almost identical variations of each other. I probably only have both of them installed because I used the meta packages to install the Xfce, MATE and Cinnamon desktop environments all on the same system. (Works fine, BTW. There's no conflict that I've been able to find.)

Now, knowing the actual name of the applications, I was finally able to create a custom executable command to make these associated applications behave the way I want, and automatically "Extract Here" when I "open" an archive filetype. Unfortunately this new association will have to be made manually for every kind of archive filetype, like ZIP, RAR, TAR.GZ, 7ZIP, whatever. But that will only need to be done once for each filetype.

The solution that I initially tried, which failed, was setting up a custom command for "/usr/bin/unzip". For some reason that did not work reliably. It was a bad solution anyway since it would only apply to ZIP files. The real solution should work for many different archive formats, just like The Unarchiver on macOS.

Of course more experienced Linux desktop users will have immediately known that the solution is "simple", for their definition of "simple". Here it is. The end result is simple, certainly, but the process is more difficult and obscure than it should have been.

THE SOLUTION
First off, if you don't have a proper general archive utility like "Engrampa" (the MATE desktop file archiver application) or "File Roller" (the GNOME file archiver application) you can install one from the Software Manager. Search for "engrampa" or "file roller". I'd recommend the non-Flatpak version that's labeled "File-roller". There's a Flatpak version labeled "File Roller". Oh, and there is a package called "Nemo-fileroller" that was already installed on my system, but you might want to install that if you use Nemo.

If you search in an application finder/launcher like the Cinnamon application menu, these applications will appear when you search for "engrampa" or "file-roller", even though they are both calling themselves "Archive Manager". So don't be confused into thinking you don't have them installed when you probably do have at least one of them. You just need to figure out the real name of the underlying binary application.

In a terminal you should find that the path to the actual binaries for these particular archive applications are:
(you don't actually need to do this, it's probably the same on your system)

Code: Select all

$ which engrampa
/usr/bin/engrampa

$ which file-roller
/usr/bin/file-roller
Here's the key to the solution. Both of these applications have a command-line option (either "-h" or "--extract-here" will work) to immediately force it to "Extract Here" without showing the application window or asking where to extract, just like the "Extract Here" option in the file browser context menus. So these GUI applications are fully capable of behaving like an invisible command-line utility, just like actual command-line utilities which have no GUI, such as "unzip".

So in the file browser, right-click on any file with the filetype for which you want to create a new custom association. Like a ZIP file. Go to "Properties", then go to the "Open With" tab. You should now see a field in the Properties dialog where you can type in a custom command. See screenshot below.

Screenshot:
Creating custom executable command in Nemo file browser
Creating custom executable command in Nemo file browser
Type in one of these commands:

Code: Select all

/usr/bin/engrampa -h
or

Code: Select all

/usr/bin/file-roller -h
Click "Set as default". That's it. You're basically done. If you don't care to refine anything or have any further understanding of how this works, you can stop reading here.

Otherwise, close the Properties dialog and test out the new association. If you double-click on the file (or single-click if your file browser is using "single click to activate"), or use the enter key or Ctrl+o (whatever you usually use to "open" a file of any kind), the archive should simply be immediately extracted into the same folder, with a folder created if necessary.

If you want to make this custom command a bit "prettier" when you see it in the context menu, you will need to edit the new ".desktop" file that the file browser just created for you in "~/.local/share/applications", which is a hidden folder due to the leading "dot"or period character. You may need to right-click in your file browser and "Show hidden" files to get there. (Keyboard shortcut in most file browsers to toggle show/hide hidden files: Ctrl+H)

You will see one or more files in that folder named like this, with some random letters/numbers at the end:

Code: Select all

userapp-engrampa-JA84Z0.desktop
userapp-file-roller-TAYA00.desktop
Right-click and open the file with any sort of text editor application, and you'll see something like this:

Code: Select all

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
NoDisplay=true
Exec=/usr/bin/file-roller -h %f
Name=file-roller
Comment=Custom definition for file-roller
Change the line where it says "Name=file-roller" to something like "Name=Extract Here (File Roller)" or just "Name=Extract Here" if you don't have multiple archive utilities installed. (There really should be a way to assign a proper name in a separate field when you're creating the custom executable command, in the first place, so this isn't necessary.)

This step is totally unnecessary, of course. But without this modification you will just see something that says "engrampa" or "file-roller" in the "Open With" context menu. It would be very easy to forget that it is a command to implement immediate extraction.

I have mine labeled like this, so I can remember both what they are supposed to do and which application they are associated with:

Code: Select all

Extract Here with Engrampa
Extract Here with File Roller
So now I see this in my "Open With" context menu:
"Open With" context menu in Nemo file browser
"Open With" context menu in Nemo file browser
Note how the default action is now "Open With Extract Here with File Roller". A bit long but very straightforward.

Fortunately if you happen to have multiple file browser applications installed this association seems to be system-wide, meaning once you make the association it should work in Nemo, Thunar, Nautilus, perhaps even Dophin or other common Linux file browser applications.

The one remaining thing that is still much easier in macOS is that The Unarchiver will automatically associate itself with most of the archive formats (dozens of them) that it can extract. And if that association ever gets broken you can easily repair the association(s) with a single button in the Unarchiver preferences. But I don't yet know of any easy way to associate this new custom command with _all_ of the archive filetypes that Engrampa or File Roller knows how to extract. So I will have to do that manually for every new type of archive I encounter. But 99% of the archives I encounter even in Linux are ZIP, RAR, TAR.GZ, 7ZIP, BZIP, ... and that's about it. So it shouldn't be a big deal.

Before I went through all this I tried to look for an alternative Linux archive application that would just naturally behave like The Unarchiver, extracting immediately rather than opening a window, but I was unsuccessful. If anyone knows of one, I would love to hear about it. I would immediately install that and uninstall Engrampa and File Roller. Someone should make one and just call it something simple like "Archive Extractor" or something.

Or, here's a relatively simple idea: For every archive utility like Engrampa or File Roller, have them install a secondary .desktop file for themselves that does exactly the same thing as the auto-generated .desktop file I showed above, with a proper name like the ones I showed above. Like "Extract Here with File Roller". An interesting fact is that those .desktop files don't show up in launchers like Albert or the Cinnamon menu when I type "extract here". They only show up in the file browser "Open With" context menus. So basically there is a simple solution to this issue that would give users the ability to make an association that will automatically extract archives much more easily, without even needing to install additional real applications. The existing archive utilities can already perform this action, the user just needs an easy pre-installed way to tell those applications to behave differently.

The End... and we all lived happily ever after.

...
..
.
Last edited by RedBearAK on Mon Mar 15, 2021 1:27 am, edited 3 times in total.
User avatar
absque fenestris
Level 12
Level 12
Posts: 4110
Joined: Sat Nov 12, 2016 8:42 pm
Location: Confoederatio Helvetica

Re: HOW TO: Automatically "Extract Here" archives without opening - Like The Unarchiver or Archive Utility in Finder on

Post by absque fenestris »

:?:

Kind of like the Finder on the Mac ...

Image


Completely normal Mint 20.0 Cinnamon or virtual LMDE 4 installation.
And in Mint 17, 18 or 19 it was no different ...
RedBearAK
Level 1
Level 1
Posts: 36
Joined: Wed Aug 19, 2020 3:03 am

Re: HOW TO: Automatically "Extract Here" archives without opening - Like The Unarchiver or Archive Utility in Finder on

Post by RedBearAK »

absque fenestris wrote: Thu Mar 04, 2021 8:06 pm :?:

Kind of like the Finder on the Mac ...

Image


Completely normal Mint 20.0 Cinnamon or virtual LMDE 4 installation.
And in Mint 17, 18 or 19 it was no different ...
If I understand the point of your screenshot, you do not appear to have correctly understood the issue I am describing, which is related to using only the relevant keyboard shortcut "open file" command (such as the Enter key, by default) to immediately extract an archive.

Do you have a way to activate the pictured context menu "Extract Here" option _without_ using the mouse? You show a screenshot of yourself using the mouse to use the context menu. This is exactly what I am trying to avoid. That is the entire point of my tutorial. I see lots of red arrows on your screenshot that seem to be meant to indicate that I am legally blind, but they are not actually helpful to my described issue. I thought it was pretty clear that I already knew that context menu option existed, as I described it in my tutorial. It's exactly the same as the option in the context menu in Windows Explorer. I hate it in Linux, and I hated it in Windows too.

I guess I need to add a screenshot with some red arrows to my tutorial? May I use yours?

With my solution, I have successfully completely bypassed the use of the context menu for extracting any archive "here" in the current folder, using one simple keyboard shortcut. Which is exactly what I wanted. My Linux file browsers now behave exactly like what I experience in the Finder. I select the file, hit "Enter" and it is immediately extracted. No mouse or context menu necessary.

By all means if I am wrong and there is a simpler way to bypass the use of the context menu and make archives "Extract Here" without using the mouse, please take a moment to explain it to me. I like to learn.
User avatar
absque fenestris
Level 12
Level 12
Posts: 4110
Joined: Sat Nov 12, 2016 8:42 pm
Location: Confoederatio Helvetica

Re: HOW TO: Automatically "Extract Here" archives without opening - Like The Unarchiver or Archive Utility in Finder on

Post by absque fenestris »

Admitted if possible I avoid the keyboard. Now my incomprehension may also have to do with the following:
Just as often as extracting a zip, I look into a zip.
If you click on the Download button from Firefox and then click on the downloaded .zip, you can either select "Open File" or "Open Containing Folder".
If you choose "Open File" you can browse the content - here an example of a zipped font:


Image


The .ttf fonts opens with Font Viewer - you can also install them as well
The .jpg opens with an image viewer (Mirage in my case)
The license .txt opens with Xed

... I'm interested in one of the two fonts, install the one font directly, and let the zip be a zip without extracting it.
RedBearAK
Level 1
Level 1
Posts: 36
Joined: Wed Aug 19, 2020 3:03 am

Re: HOW TO: Automatically "Extract Here" archives without opening - Like The Unarchiver or Archive Utility in Finder on

Post by RedBearAK »

absque fenestris wrote: Thu Mar 04, 2021 10:47 pm Admitted if possible I avoid the keyboard. Now my incomprehension may also have to do with the following:
Just as often as extracting a zip, I look into a zip.
If you click on the Download button from Firefox and then click on the downloaded .zip, you can either select "Open File" or "Open Containing Folder".
If you choose "Open File" you can browse the content - here an example of a zipped font:
I know a lot of people work like that, and I'm glad that process works for you. But my process is always "Open Folder" and extract. With SSDs these days I barely have time to blink before it's done extracting. Then I can go through the files and open or preview anything I want, and trash whatever I don't want to keep. I don't have any interest in interacting with a third application.

The paradigm of the archive manager encourages people to use archives as if they are folders, and I just don't enjoy that.

So I came up with a way to make my Linux file browsers behave the way I expect, and stop annoying me with unnecessary steps. And then I wrote a tutorial to teach myself to do it again in the future. 8)
Post Reply

Return to “Tutorials”