7 ms·
CGrep: a context-aware grep for source codes
- chris_wot 12y agoI'm not sure where the documentation is.
- meowface 12y agoYeah, I struggled with that as well. The landing page of any software project like this should at the least have a lot of example syntax with output, plus a glaringly obvious link to full documentation.
- timdorr 12y agoIt's in the README at the repo: https://github.com/awgn/cgrep https://github.com/awgn/cgrep
- chris_wot 12y agoAny examples?
- thinkpad20 12y agoIt's following the illustrious Haskell tradition of barely-documented code. (Non-snarky follow-up: Haskell code is often woefully under-documented, for whatever reason. Possibly because people think that the type signatures are sufficient, or possibly because Haskell code lends itself to concision and documentation runs counter to that, or possibly because Haskell projects are often the result of one person's work, diminishing the need to explain oneself. In any case, it's an unfortunate fact of many Haskell apps and libraries.)
- gingerlime 12y agoThis looks like a cool idea. I think a couple of (neat!) examples, stuff you can't easily do with normal grep, will go a very long way. The list of features is secondary in my opinion.
- nichochar 12y agoSeconded
- hunt 12y agoTaking this idea further, you could perhaps also have examples of use for each language.
- stcredzero 12y agoYou basically had this with the Smalltalk refactoring Browser, where each search popped up displayed in a browser window. Then you could easily AND such searches together by executing a script in the browser window. Slightly more sophisticated combinations were possible with just a few lines of scripting. On top of that, everything above applied to syntax-driven rewrites and refactorings.
- yawniek 12y agoa binary for os x would be nice, since installing cabal/ghc currently is a bit of a pain
- mattgreenrocks 12y agoIsn't that just a brew install away?
- oinksoft 12y agoIt is a package install away: http://www.haskell.org/platform/mac.html http://www.haskell.org/platform/mac.html On my machine it is significantly slower than `ag` (Silver Searcher) for basic searches, but it should install and run.
- yawniek 12y agook thats a way. i usually like to install stuff with homebrew.
- wangweij 12y agoExamples or it didn't happen.
- invernomut0 12y agoe.g. $ cgrep -r --header "stdio.h" to search recursively for headers $cgrep -r --identifier VARname to search for a variable etc..
- githulhu 12y agoDarn, no SQL support. I often find myself wishing something like this existed for SQL, so I could, say, find all places where field X in table Y is updated, or referenced in a WHERE clause predicate, etc.
- mh- 12y agointeresting request; I've wanted something like this before but never enough to really look for it. I'm surprised there isn't a tool that can do this already.. perhaps under the guise of refactoring?
- cheez 12y agoHow do I build this for Windows? I think I have something Haskell related installed because I see lambda as an icon on the .hs files.
- jasonlfunk 12y agoWhat is the difference between this and ack? http://beyondgrep.com http://beyondgrep.com
- netghost 12y agoThis is aware of some basic language semantics like literals, identifiers, etc. Or so it seems. Peek at the github page https://github.com/awgn/cgrep https://github.com/awgn/cgrep for a little more info.
- bogolisk 12y agoblah.c: void foo(item *x) { x->blah(1, 2, 3); x->blah (4, 5, 6); blah (7, 5, 1); foo (4, 5, 6); x->blah (4, 5, 6); } void foo2(item y, item *x) { y.blah(1, 2, 3); y.blah (4, 5, 6); blah (7, 5, 1); foo (4, 5, 6); x->blah (4, 5, 6); } search in blah.c for a call to blah() with 5 as 2nd argument from any structure or pointer. cgrep --code --semantic '_1 . OR -> blah ( _2 , 5, _3 )' blah.c output: blah.c:6: x->blah (4, 5, blah.c:7: 6); blah.c:10: x->blah (4, blah.c:11: 5, 6); blah.c:18: y.blah (4, 5, blah.c:19: 6); blah.c:22: x->blah (4, blah.c:23: 5, 6);
- res0nat0r 12y agoAny examples or reasons why I should use this over the_silver_searcher?
- WorldWideWayne 12y agoIt really sucks that 15 languages that people use less than C# are supported before anyone thinks of adding support for C#. Why does everyone hate Microsoft's languages and love Apples?
- TallGuyShort 12y agoThe most reasonable explanation is that this is developed by (an) Apple user(s) and adding support for Apple's languages is simply easier and more valuable than adding languages for a platform they don't use. If it's worth it to you or other C# users, I'm sure they wouldn't mind you submitting a pull request.
- WorldWideWayne 12y agoThey actually do support C#, but I missed it because I read the list too quickly.
- djeikyb 12y agoI've not tried it, but the linked article claims c# is supported. Quote: Languages support for Awk, C, Cpp, Chapel, Csharp, Css,
- WorldWideWayne 12y agoYou know - I totally missed it because of the way it was written. Sorry for complaining! Thanks so much :)
- egonschiele 12y agoI've thought about something like this before, and I'm really excited to see how fully-featured it is. Written in Haskell is also a big plus.
- mcrider 12y agoWould love a UI for this and an editor -- I still use TextWrangler/BBEdit daily to grep large chunks of source code and then edit in place (e.g. for refactoring). Just getting the search results requires opening up each file individually then editing, which is just too slow.
- ushi 12y agoFunny, there was a bell-labs project with same name. It seems to be dead[0], but when we travel the time a few years back, we get a wonderful project homepage[1]. [0] http://www1.bell-labs.com/project/wwexptools/cgrep/ http://www1.bell-labs.com/project/wwexptools/cgrep/ [1] https://web.archive.org/web/20080513225010/http://www1.bell-labs.com/project/wwexptools/cgrep/ https://web.archive.org/web/20080513225010/http://www1.bell-...
- edderly 12y agoI was curious, but had no idea how to use this on Ubuntu sudo apt-get install haskell-platform download and extract the tarball cd awgn-cgrep-8af1beb cabal cgrep.cabal Unfortunately what stops me using it on a large codebase is that I can't exclude directories like .repo (not sure about .git).
- volune 12y agoHow does this compare with Ack?
- nodivbyzero 12y agoHave you tried https://github.com/zeux/qgrep https://github.com/zeux/qgrep ??? Fast regular expression grep for source code with incremental index updates
- kumarishan 12y agocan it be integrated with sublime text ?
- michaelmior 12y agoJSON output is incredibly useful in combination with jq[1] for processing the output. Some things become much easier than with standard *nix tools IMO. [1] http://stedolan.github.io/jq/ http://stedolan.github.io/jq/