View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide

grep your helpfiles

Home   How To   Code Pool   Public Library   Theory   Events
Use grep to search for keywords in the help directory.

q = q ? ();
(
q.grep = {|pattern="JITLib", where = "Help", includes(["rtf", "html", "scd"])|
	var p, l;
	var str;
	var includesList;
	var resultList = List();
	
	includes.isString.if({
		includes = [includes]
	});
	
	includesList = includes.collect{|name|  " --include=*.% ".format(name)}.join;

	str = "cd %; grep -r % \"%\" -l *"
		.format(where, includesList, pattern);
	
	p = Pipe.new(str, "r");							// list directory contents in long format
	l = p.getLine;								// get the first line
	
	while({l.notNil}, {resultList.add(l); l = p.getLine; });	// post until l = nil
	p.close;										// close the pipe to avoid that nasty buildup
	resultList
}
)

// grep for "spawn" in quarks directory
q[\grep].("spawn", "~/Library/Application\\ Support/SuperCollider/quarks".standardizePath, "html").printAll; ""

// grep for "spawn" in all helpfiles
q[\grep].("spawn", "Help").printAll; ""



contributions:

in early spring '07

Link to this Page