Hi,
many times I use Geany's "find in files" function to search for some string inside directory. The problem is that results are not sorted at all (at least, I cannot find a critera: it isn't file timestamp or filename).
Would it be possible to sort the result alphabetically (or any other way). Just piping grep to sort(1) would be sufficient to me.
Thanks,
P.S. I guess I don't have to tell you that Geany is great! because you already know that :)
On Thu, 17 Dec 2009 14:02:38 +0100, Milan wrote:
Hi,
many times I use Geany's "find in files" function to search for some string inside directory. The problem is that results are not sorted at all (at least, I cannot find a critera: it isn't file timestamp or filename).
Would it be possible to sort the result alphabetically (or any other way). Just piping grep to sort(1) would be sufficient to me.
I'm not sure it's wise to include that into Geany itself. Piping the results simply to sort should be simple enough but then there is Windows (where 'sort' doesn't exist or at least behaves different from Unix-like 'sort') and, more importantly, once we would implement it, users would like to configure sorting criteria and such. Then we would need to provide a GUI for that which IMO just bloats that feature to some unnecessary extend. Alternatively, a 1.5 minute hacked shell script is attached which simply wraps the call from Geany to grep, calls the real grep and then sort its output. Simply save that script into your filesystem, make it executable (chmod +x ...) and enter the path to the script in Geany's preferences dialog, Tools tab as Grep command.
P.S. I guess I don't have to tell you that Geany is great! because you already know that :)
Hehe, thanks.
Regards, Enrico
On Thu, 17 Dec 2009 14:02:38 +0100 Milan Babuskov milan.babuskov@gmail.com wrote:
many times I use Geany's "find in files" function to search for some string inside directory. The problem is that results are not sorted at all (at least, I cannot find a critera: it isn't file timestamp or filename).
AFAIU, filenames are sorted so long as you don't use the 'Recurse in subfolders' option. Maybe this could be fixed, but I'm not sure it's worth implementing in Geany - see below.
Would it be possible to sort the result alphabetically (or any other way). Just piping grep to sort(1) would be sufficient to me.
Sorting grep's output is not efficient - only the file list needs to be sorted, and as Enrico mentioned, it's not portable.
The real problem is that grep doesn't support recursive searching well enough, but you could use the following script for Geany's Grep tool:
http://download.geany.org/contrib/grep2ack.pl
Remember to chmod u+x.
This uses ack* and (as of today) sorts filenames too. * http://betterthangrep.com/
Ack skips binary and generated files.
Regards, Nick