Skip to content

Instantly share code, notes, and snippets.

@vijayhardaha
Last active October 6, 2023 11:03
Show Gist options
  • Save vijayhardaha/c40455b74a01794fe9742e8988295612 to your computer and use it in GitHub Desktop.
Save vijayhardaha/c40455b74a01794fe9742e8988295612 to your computer and use it in GitHub Desktop.
Effortless Cleanup: Removing .DS_Store Files Recursively with One Command

Alias for Removing .DS_Store Files

If you're a macOS user, you've probably come across those pesky .DS_Store files that macOS creates to store metadata about directories. These files can clutter your file system, and sometimes you just want to get rid of them.

Here's a useful alias that finds and deletes all .DS_Store files within the current directory and its subdirectories, while providing verbose output so you can see which files are being removed:

alias rm-dsstore='find . -name ".DS_Store" -type f -exec rm -v {} \;'

To use this alias, add it to your shell configuration file (e.g., .bashrc, .zshrc) and then run source ~/.bashrc (or the corresponding file for your shell) to apply the changes. After that, you can simply use rm-dsstore in your terminal to clean up those .DS_Store files hassle-free.

Conclusion

In summary, this one-command solution makes it easy to clean up .DS_Store files not only from your local directories but also from your GitHub repositories, ensuring a clutter-free and polished project presentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment