Aimlessly Going Forward

blog by Tomas Sedovic

Ditch that unpack-all-the-things shell script for atool

tech, tips

You know that feeling of dread when you unzip something your idiot Windows-using friend (“more of an acquaintance, really”) sent you and it spews a zillion files all over your $PWD.

“Why don’t they pack up the folder just like every sensible person familiar with tar?”

They’re using Windows, remember? Right-click, select “extract to folder stuff, reboot to apply changes.

You could do unzip -d of course but that’s a hassle when there is just one file inside plus then you also have to remember that it’s unrar x and tar -C <target_dir> -xf and why isn’t there a tool that does the smart thing aren’t computers supposed to make the life easier sheesh.

And being the clever programmer you are, you calculate that spending 20 minutes automating a task that saves 5 seconds is totally worth it.

Except it takes twice as long because you end up checking all the possible file extraction tools (“if I’m spending the time might as well do it right”) installing the ones you din’t even know existed and making sure it all works and “what’s the right syntax for bash switch again?”

And then you want to share this perfect little tool with everyone because open source and if you’re lucky someone will ask the dreadful question “why don’t you just use atool?” .

Thanks, smartass, why didn’t you say so a week ago when I started coding this?

So yeah, atool. It’s a collection of tools that do god knows what, but it also contains aunpack which does exactly what you want only right.

You type aunpack or .rar or .tar or .tar.gz or .tgz or or .tar.xz or .tar.ohmygodz and it will extract it to a temp directory. Then it looks inside. If there’s only one item, it will move it to PWD. Otherwise it will rename the temp dir to the archive file name sans the extension.


And it’s already packaged for ubuntu:

apt-get install atool

and fedora:

yum install atool

and rhel:

yum install atool

and debian

apt-get install atool

And suse

zypper in atool

and arch

pacman -S atool
using the more arcane invocations of pacman may wake up The Old Ones as a side effect

and gentoo

emerge atool

and mint

apt-get install atool

and mac os:

brew install atool

Not only is atool in everywhere the package is always called the same! Badass.

I know aunpack is’s a bit of a mouthful (handful? keyboardful?), but I’m sure you’re able to alias it as unblar or ex (e is already taken up by emacs, obviously).

Now someone write this for package managers, PLEASE!

Screenshot and link to the website for the Dose Response game

Hi! I wrote a game! It's an open-world roguelike where you play an addict called Dose Response. You can get it on the game's website (pay what you want!), it's cross-platform, works in the browser and it's open source! If you give it a go, let me know how you liked it, please!