Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I have found this bash function a while ago. It doesn't save all the steps, but it shouldn't be too difficult to add them, too.

https://gist.github.com/Fannon/41b0a6104435943cd826



I used to use something similar, but atool is far superior. It handles quite a few situations, but the most important is that it will decompress into the current directory (as a normal "tar zxvf foo.tar.gz" or "unzip foo.zip") if-and-only-if there was exactly one file or directory at the top level of the in the archive. If the archive was packaged badly, it will leave the resulting files in the temporary directory it creates. Also, atool leave the file(s) in the temporary directory in the event of a name collision, so you protected from the risk of clobbering existing files.

Without atool you have to either 1) create a temporary dir youself and do the dance I showed above, or 2) always inspect every archive before you decompress it to see if it has multiple top-level files, or 3) accept that typing "tar xvf" or similar will sometimes spam your current directory (often $HOME) with thousands of files.

Similar to how git tends to remove mental blocks around branching (you not longer have ot worry about the cost of making an arbitrary change), atool frees you from having to worry about how an archive was created. This has, in practice, saved huge amount of time and mental effort.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: