This blog post details how to automatically remove macOS-specific files (.DS_Store
and ._*
) from external drives upon ejection. The author uses a combination of AppleScript and a LaunchAgent to trigger a cleanup script whenever a volume is ejected. The script leverages dot_clean
to efficiently delete these often-annoying hidden files, preventing their proliferation on non-macOS systems. This automated approach replaces the need for manual cleanup and ensures a cleaner experience when sharing drives between different operating systems.
Milo Fultz's blog post details a method for finding the oldest lines of code in a Git repository. The approach leverages git blame
combined with awk
and sort
to extract commit dates and line numbers. By sorting the output based on these dates, the script identifies and displays the oldest surviving lines, effectively pinpointing code that has remained unchanged since its initial introduction. This technique can be useful for understanding the evolution of a codebase, identifying potential legacy code, or simply satisfying curiosity about a project's history.
Hacker News users discussed various methods and tools for finding the oldest lines of code in a repository, expanding on the article's git blame
approach. Several commenters suggested using git log -L
for more precise tracking of specific lines or functions, highlighting its ability to handle code moves and rewrites. The practicality of such analysis was debated, with some arguing its usefulness for understanding legacy code and identifying potential refactoring targets, while others questioned its value beyond curiosity. Alternatives like git-quick-stats
and commercial tools like CodeScene were also mentioned for broader code history analysis, including visualizing code churn and developer contributions over time. The potential pitfalls of relying solely on line age were also brought up, emphasizing the importance of considering code quality and functionality regardless of its age.
Summary of Comments ( 18 )
https://news.ycombinator.com/item?id=42987848
Commenters on Hacker News largely appreciated the simplicity and directness of the provided AppleScript solution for removing macOS-specific files from external drives upon ejection. Some highlighted the potential for data loss if used carelessly, especially with networked drives or if the script were modified to delete different files. Others offered alternative solutions, including using
dot_clean
, incorporating the script into a Hazel rule, or employing a shell script withfind
. The discussion also touched upon the annoyance factor of these files on other operating systems and the historical reasons for their existence, with some suggesting that their prevalence has diminished. A few commenters mentioned more robust solutions for syncing and backing up, which would obviate the need for such a script altogether.The Hacker News post "Automating the cleaning of macOS-specific ( ._ and .DS_Store) files on Eject" generated several comments discussing the author's approach and alternative solutions for managing macOS-specific files on external drives.
One commenter questioned the necessity of the script, pointing out that
.DS_Store
files are generally hidden and don't cause issues for most users. They also mentioned that these files serve a purpose for macOS systems and deleting them might have unintended consequences. This commenter suggested educating Windows users about hiding system files instead of automatically deleting them.Another commenter highlighted the potential for data loss if the script were to malfunction, emphasizing the importance of robust error handling and thorough testing, particularly when dealing with file system operations. They proposed a more cautious approach involving moving the files to a temporary trash directory instead of immediately deleting them.
Building on this cautionary theme, another user recounted a personal experience of data loss due to a similar automated cleanup script, reinforcing the risks associated with such solutions.
One commenter offered an alternative using
dotfiles
, a common way to manage system configurations, suggesting that the script could be integrated into a user's dotfiles repository for better version control and portability.Another user suggested a different technical approach, recommending the use of a shell script triggered by the
eject
command itself, rather than relying on external tools or applications. They outlined a basic shell command structure for accomplishing this.Some users discussed the broader issue of cross-platform file management and the challenges posed by operating system-specific files. One commenter noted that similar issues arise with Windows-specific files like
Thumbs.db
and advocated for greater awareness and tolerance of these files across different operating systems.Finally, several comments focused on the technical details of the script itself, discussing the use of specific commands and suggesting improvements to its logic and error handling. One user questioned the efficiency of the script's find command and suggested an alternative approach using
locate
. Another user pointed out a potential bug in the script's handling of spaces in filenames.In summary, the comments section offered a mix of perspectives, including questioning the need for the script, expressing concerns about data loss, suggesting alternative solutions, and delving into the technical specifics of the script's implementation. The comments highlighted the complexities and potential pitfalls of automated file system manipulation and emphasized the importance of caution and thorough testing.