← til

Keeping a folder of snippets

November 29, 2020
development

I had used Github's gists for saving snippets of useful code that I have used to solve a problem but might still need in the future. This had usually included snippets on how to do something with Ruby, bash, or vim.

However, I got tired of saving everything in Github and decided to replace it with the local alternative.

My first solution was putting everything in a single file for every project that I was working on. This was added to the global gitignore (~/.gitignore):

snippets.rb

This enabled having context for my snippets. I could place project-related snippets in that project's root directory while keeping a global snippets file in my home directory.

However, this has become a mess, for obvious reasons, so I've recently added this to my global gitignore:

snippets/

While still giving me all the benefits of snippets.rb, this also allows separating snippets into files, which is much more manageable.

@shime_sh Hrvoje Šimić
0 kudos