Search code inside a Github project

前端 未结 7 1811
被撕碎了的回忆
被撕碎了的回忆 2020-11-29 14:54

Is there a way to grep for something inside a Github project\'s code?

I could pull the source and grep it locally, but I was wondering if it\'s possible through the

7条回答
  •  天涯浪人
    2020-11-29 15:48

    UPDATE

    The bookmarklet hack below is broken due to XHR issues and API changes.

    Thankfully Github now has "A Whole New Code Search" which does the job superbly.


    Checkout this voodoo: Github code search userscript.

    Follow the directions there, or if you hate bloating your browser with scripts and extensions, use my bookmarkified bundle of the userscript:

    javascript:(function(){var s='https://raw.githubusercontent.com/skratchdot/github-enhancement-suite/master/build/github-enhancement-suite.user.js',t='text/javascript',d=document,n=navigator,e;(e=d.createElement('script')).src=s;e.type=t;d.getElementsByTagName('head')[0].appendChild(e)})();doIt('');void('');
    

    Save the source above as the URL of a new bookmark. Browse to any Github repo, click the bookmark, and bam: in-page, ajaxified code search.

    CAVEAT Github must index a repo before you can search it.

    Before the Bookmarklet

    Abracadabra...

    After - Look in the second menubar after the leftmost tabs: Files, Commits, Branches...

    Here's a sample search from the annotated ECMAScript 5.1 specification repository:

    Sample search in the annotated ECMAScript 5.1 specification repository

提交回复
热议问题