I use the homebrew package manager and the z-shell. I'm trying to implement a function to create a list of available packages that would be accessible to the grep function. Here's what I've got so far:
function bsearch() {
br开发者_如何学Goew search | less >| ~/.brewsearch; grep $1 ~/.brewsearch
}
The problem I'm facing is that I'm not sure of what to put in place of $1. I'd like to be able to run the command as follows:
bsearch foo
but what ends up happening is that the function ends up looking for a file because of the argument $1.
In short, the question seems to be: how do I allow for a string in this function? (I'm new to all this).
Thanks for the help!
You don't need to write a function. Just run brew search foo
.
The command also accepts a regular expression between slashes, e.g. brew search /foo/
Check Homebrew's man page (man brew
) for more details.
精彩评论