Out, damn tilda!

Just about any modern text exitor has a way of creating backup files. As any Emacs or jEdit user will tell you, one of the simplest (and at times one of the most annoying) ways of going about this is to create a file with the same name as the original, and append a tilda (~) to the end of the filename. When editing several files in different directories, this can lead to a whole mess of tilda-files lurking around, taking up space and just generally making a nuisance of themselves. Instead of manually searching through all of my directories and removing these files by hand, I’ve made use of the find command to run search-and-destroy missions these tilda files. All I did was add this line to my .bashrc:

alias emacs-clean='find . -name '*~' -exec rm {} \;'

Pretty simple, really. Note that this will not, however, remove any dot-tilda-files (backups of “hidden” files prefixed with a “.”; e.g., .bashrc~) that happen to be hiding out in your directories. To take care of these, you could add the following to your .bashrc:

alias dot-emacs-clean='find . -name '.*~' -exec rm {} \;'

Now you can happily edit away without worrying about those irksome tilda-files. Happy coding!

Update: It was brought to my attention that the correct spelling of the word is ’tilde’. However, since I’m unwilling to change my pronunciation of the word from ’til-duh’ to ’til-deh’, I’m equally unwilling to change the spelling of the word in this post. Thanks anyway, Bob! 🙂

Update: I’ve since made a change to my emacs-clean script so that it includes dot-files. I use the -or flag, like so:

alias emacs-clean='find . -name "*~" -or -name ".*~" -exec rm {} \;'


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s