How to create a bash function with variable parameters/arguments to grep several keywords/tags
Posted
by
CornSmith
on Stack Overflow
See other posts from Stack Overflow
or by CornSmith
Published on 2012-10-04T20:25:32Z
Indexed on
2012/10/04
21:38 UTC
Read the original article
Hit count: 197
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?
© Stack Overflow or respective owner