Pakke and Unpakke

I’m sure five times a day, you download some code in some form of compressed file format.  Could be a .zip, or a .tar.bz2 or a .tar.gz, maybe its even a .7z.  For me, its almost everyday and the mental logic goes like this:

1) Downloaded some file off the Internet
2) ‘ls -al’
3) Looks like a zip, so I’ll use ‘unzip’

And then if it happens to be a .tar.bz2, I need to run ‘tar xvfj’ instead of ‘tar xvfz’. Not difficult, but really!, can’t a computer figure this out.

This is what unpakke does for you.  Whatever the compressed file format, it will decompress it with the appropriate options using system compression utilities.  Still a few corner cases to address but more or less it just does it right, no need to think about it.  So now all you have to do is run:

unpakke asdf.tar.gz

It also removes the compressed archive after successfully extracting the content (unless you pass the ‘–keep’ argument).  Handy right?  The opposite case is addressed with pakke.  So if you find yourself compressing a bunch of files and don’t really remember the exact syntax or just don’t want to type

tar cvfz folder1.tar.gz folder1

Which is actually quite redundant BTW.  Never more! Just try this:

pakke folder1

You will notice ‘folder1’ is compressed into the user specified compression format. Done. You can configure the format by running and all future pakke calls will use that format:

pakke config --global compressor tar.gz

Try out Pakke and Unpakke with a one-line install (if you already have all the os tools and npm/node installed)

npm install -g pakke unpakke

For the os tools:

brew install zstd xz p7zip