How can I Spotlight search exclusively in `.txt` files in `~/.` on my disk? I was talking to Mr. Ramanujan at his desk when he gave me his cell phone number. 

I recall I had a text editor open and I wrote the number in a file. Normally I store such details in ~/phone-numbers.txt, but that time I seem to have inadvertently written in another file.

No worries. I use Spotlight Search to search for Ramanujan, but it produces irrelevant search results of the famed mathematician, on and off my computer, especially off.

How can I search for Ramanujan solely in .txt files in files rooted at ~/.?
In terminal app using the command line, this is easy to do.

mdfind -onlyin ~ Ramanujan|grep txt


You could make a complex query and get rid of the pipe to grep, but the above should work very quickly. You could probably assemble a finder search as well with about 12 clicks if you couldn’t use the command line tools.