2018-week-13

A journaling experiment for March 26-30th, 2018

I am live-blogging my entire process and thought patterns around work this week. Follow along!

Frequently Asked Questions

Posts:

- Sat at 10:46 - Fixing Bushwhich
- Fri at 14:03 - Searching files and filenames with ag
- Fri at 08:57 - Carbon Zerow
- Wed at 15:51 - Thesis and Open Source Cities
- Wed at 14:08 - After lunch
- Wed at 12:26 - Social Networks
- Wed at 11:39 - Roadtrip to Pittsburgh
- Wed at 11:21 - Monteregian hills, larks, and Mohawk
- Tue at 11:52 - Tuesday morning

All content CC-BY-NC © 2018 Richard Littauer.

Searching files and filenames with ag

I use a folder called projects for holding my GTD projects, in Markdown files. I wanted a way to search for the occurrence of a word - say, fritz if I wanted to message my friend @fritzvd - but also to find that word if it was in a filename. I use the silver searcher (ag) because it is faster than grep, but I couldn’t find a way in the man files to combine both -i for ignore case and -g for finding patterns in filenames. A short trip to my ~.bash_profile later, and I’ve got this:

function aga() {
  ag -i $1
  ag -ig $1
}

Maybe not the most convenient, but it should work for now.

Ironically, I had to use grep to find that command in my .bash_profile, because ag doesn’t have the -n5 command I wanted. Let’s fix that.

A quick trip to the man ag files later, and I’ve got this: cat ~/.bash_profile | ag 'ag' -C5. Glad I won’t have to see that problem again.


Beam me home, Scotty!