Mårten Björk / Activity
There seems to be some confusion around what this script does and whether it’s dangerous. Here’s the TL;DR:
• This script is irreversible.
• It deletes more than your Sketch history.
What does it do, exactly? What are you going to lose? What precautions should you take? Here’s the breakdown command-by-command:
> sudo cd /
This changes directories (cd is change directory) to the top-level directory on your file system, the root. It uses sudo, for some reason, which is unnecessary. The sudo command gives you elevated permissions. You don’t need special permissions to go to the root directory.
> sudo ls -l .DocumentRevisions-V100
This lists the contents of the folder you’re about to delete, so that you can see it in the Terminal. Here, sudo actually is necessary; the .DocumentRevisions-V100 directory is protected, and for good reason—it contains all of the previous versions of every file on your machine that uses OS X’s version history system. That means Keynote, TextEdit, etc.
To be clear, the above means that this script does not just delete the version history of Sketch files. It deletes all version history for many different apps. If you don’t want to lose all of that, don’t run this script. Furthermore, you should always make sure you have a backup of your important files, especially before mucking about in the innards of your machine. The original post should have told you these things because (a) Dribbble is not a community of engineers, and (b) these commands are irreversible.
> sudo rm -rf .DocumentRevisions-V100
This does the actual deleting. It removes the .DocumentRevisions-V100 folder and all of its contents, including all file version history for a variety of applications. You should make sure that you know exactly what you’re going to lose before you execute this command, and as always you should have an off-disk backup of anything you can’t afford to lose.