Show HN: Clean Your Mac with a Script

(github.com)

38 points | by hkdobrev 7 hours ago ago

15 comments

  • duskwuff 2 hours ago

    1) Deleting individual files from ~/Library/Caches based only on their mtime is not safe - especially since some files (like files extracted from archives or downloaded over HTTP) may be stored with an mtime matching the source data. At a minimum, you really need to base this on the last access time; even then, I would be hesitant to delete individual files from an application's cache while leaving others.

    2) /tmp and /var/tmp are cleared on reboot. Clearing them manually is probably not worth the hassle.

    3) A week is way too short as a default for DAYS_TO_KEEP. A more appropriate value might be on the order of 30 - 90 days.

    4) brew doctor is purely a diagnostic tool; it doesn't perform any maintenance operations. It doesn't belong in this script.

  • ryandrake 19 minutes ago

    It would be really great if operating systems (and applications) didn't have to be constantly cleaned up in the first place. Way too much software uses the user's filesystem as their personal dumping ground for crap. Crap that they leave around when not running and crap that they leave behind when they're uninstalled. My ~/Library directory is currently 47G(!!) and it's mostly a bunch of shit that I have no idea whether I need or not. As the user, I should be the one who decides what to put on my filesystem, not some application developer. We've completely lost control of our own filesystems.

  • domoregood 21 minutes ago

    Loved AppleJack (free), back when it worked:

    https://applejack.sourceforge.io

    Nowadays, Onyx (also free) tends to do the trick:

    https://www.titanium-software.fr/en/onyx.html

    Does this script close any gaps left by Onyx's MAINTENANCE routines?

  • cpursley 3 hours ago

    Yep, df gonna run this rando script with such a detailed and inspiring README...

    (in all seriousness folks, if you're gonna show HN, spend some time on your README, docs, etc).

    • antihero 3 hours ago

      The README should be better but the script is like 100 lines or so.

      The main issue I'm finding is that `find` seems extremely slow at deleting things.

      • PeterWhittaker 3 hours ago

        And half of that is parsing the options and processing the dry run...

        The script is clean and straightforward.

  • CharlesW an hour ago

    I'm sure this script is wonderful, but it's not a replacement for the apparent target of the author's disparagement, created by the legit folks at MacPaw (established 2008). A good place to start is the free Unarchiver, which can extract anything you can throw at it. https://macpaw.com/the-unarchiver

  • seer an hour ago

    I’ve found that with a good dotfiles[1] setup + cloud storage, it is better to just reset the whole system and re-install whatever is needed.

    The ability to do that is actually quite powerful as both disaster recovery and getting new hardware - it is in my mind so much cleaner to just install everything again. The built in migration tools have always done too little or too much for my taste. Dotfiles feel just right.

    Funny enough hkdobrev introduced me to this philosophy almost 15years ago which I still use to this day and try to spread wherever I am. Thank you!

    [1] https://github.com/webpro/awesome-dotfiles

    • voidfunc 37 minutes ago

      Yep this is my setup. I'm a Windows/WSL2 or Linux-native person depending on machine but I basically have my system tune-up automated. The Windows+WSL2 one is a little more finicky because I haven't really desired to deep-dive on PowerShell but otherwise I can basically provision new machines really quickly for myself and it's just so much easier than maintaining a long-lived system.

  • Jiahang 11 minutes ago
  • chasil 3 hours ago

    Isn't zsh the current #!/bin/sh on MacOS?

    Why is this written for bash, which isn't getting recent changes?

    • alsetmusic 2 hours ago

      Compatibility with older devices that aren't eligible for recent OS updates, I would assume?

      Or, if the person is like me, they're more comfortable in Bash after years of it being the default. Hacking around in a less-familiar shell seems like a bad idea if it's optional when deleting data, regardless of what's currently the default. (I realize that zsh can execute commands with Bash syntax, that's not my point.)

      • duskwuff 34 minutes ago

        zsh has been available in every version of macOS since 10.0 - there's never been a version where bash was installed but zsh wasn't.

  • rgbjoy 3 hours ago

    Try adding a way more detailed readme.

  • 2 hours ago
    [deleted]