Preview an archive contents without extracting it

Solution 1:

Manually

  • zip: unzip -v FILE.zip
  • tar.gz: tar tvzf FILE.tar.gz
  • tar.bz2: bunzip2 -c FILE.tar.bz2 | tar tvf -
  • .7z: 7z l FILE.7z

PS: For .7z you need to run brew install p7zip first

Extend less to work the same way it does under Linux

  • Install lesspipe

     brew install lesspipe
    
  • Add the following lines to .bashrc (or the profile of whatever shell you use)

     if [[ -x /usr/local/bin/lesspipe.sh ]]; then
         export LESSOPEN="|/usr/local/bin/lesspipe.sh %s"
         export LESS_ADVANCED_PREPROCESSOR=1
     fi
    
  • Source .bashrc or open a new terminal tab

Solution 2:

I was able to successfully accomplish what GEdgar posted using BetterZipQL (available here: https://macitbetter.com/BetterZip-Quick-Look-Generator/). Just select an archive and tap the spacebar.

BetterZipQL

Confirmed it works with 7z and rar archives, and also works on archives at least 700 MB in size, which was the largest I had handy.

Solution 3:

MacOS Finder allows viewing the names of the files in a ZIP archive without extracting. But, since it takes more than three clicks to do it, perhaps this is not what you want.

How to do it. Mojave 10.14.5
In the Finder, select the ZIP file.
ready.zip
Hit the space bar. You see a window about the ZIP file.
mage In that window, click on the little triangle ▶︎ to see the list of files contained in the archive.
image
If there are folders within folders, use the new triangle to see them.
image

I haven't tried this with other types of archives. Of course, if the ZIP is encrypted, you may see less about it.