After Git, I did the same for Mercurial repository. Mercurial has similar setting as you do in Git, you add the following to your ~/.hgrc:

[ui]
ignore = ~/.hgignore

This ~/.hgignore has same syntax as the ones you use in repository. You can specify more than one ignore pattern file, from man hgrc,

This option supports hook syntax, so if you want to specify multiple ignore
files, you can do so by setting something like ignore.other = ~/.hgignore2.
For details of the ignore file format, see the hgignore(5) man page.

For a very long time, in Mercurial or in other version control repository, I always reluctant to add and to commit .hgignore because some ignore patterns are for the editor I use, i.e. Vim, and they are not for other contributors. If everyone puts their pattern for temporary or cache files used by their favorite, then this ignore file could be as long as your main code file. (Just joking)

Anyway, with this setting, you can put those into your personal ignore file and do not intervene with repositorys ignore file. As for compiled or generated files during testing, they may be more suitable to stay in repositorys ignore file, because everyone needs to ignore them while developing. But there is nothing to stop you from putting them in your personal ignore file.