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
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:
Type in one of these commands:
Code: Select all
/usr/bin/engrampa -h
Code: Select all
/usr/bin/file-roller -h
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
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
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
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.
...
..
.