How to create a bash function with variable parameters/arguments to grep several keywords/tags
- by CornSmith
I'm using the :!grep "tag1" filename | grep "tag2" filename | grep -n "tag3 or more" filename command in vim to search for my code snippets based on their tags (a simple comment at the top of a snippet) in one big file. I use snippets to remember tricky things.
This is painful to write out each time. I'd like to make an alias, or function to do something like this:
:!greptag tag1 tag2 ... tag39
And it should search the current doc and return the lines with all the tags on them.
Vim is set to interactive shell mode so that it can parse my bashrc for aliases/functions.
set shellcmdflag=-ic
How can I construct a function that allows for variable arguments like this in bash?