Reputation: 2588
I know it is possible to search code inside a repo, by typing in the search box:
my-keyword repo:user_name/repository_name
But since I'm using a lot of projects everyday, and love to go deep inside the source code to see how this or that works, it very quickly becomes annoying to have to enter repo: user_name/repository_name
part each time I want to search something.
Is there any way to search code quickly inside the current viewed repo source code?
If I'm currently on the frankenstein/monster
repo, I want to be able to search for the create_life
method without having to enter repo: frankenstein/monster
in the search box, since I'm already in this repo.
(It's as if you are working on a file in your text editor, press Ctrl+F and need to enter the filename of the current file)
Upvotes: 6
Views: 15808
Reputation: 11741
There is a brand new search provided by github.
For advanced needs, like searching a specific repo or user etc., use advanced search.
Upvotes: 0
Reputation: 1329082
Update May 2013: see "Repository Search on all Repositories"
Today we are allowing you to search your own public repositories and any private repositories you have access to.
When you're on a repository page, you'll see an indication that you're searching that repository by default:
Original answer (February 2013)
I didn't find any "repo:current
" or other convention that would specify the default repo for a "Code" search.
I usually do my search in a separate windows, with "Code" selected and the "repo:username/reponame
" already filled in.
I only add the keyword I need and click enter.
I repeat the process multiple time, changing only the keyword, but if a result is of interest, I open it in another tab, in order to preserve the search page and their fields.
Upvotes: 6
Reputation: 2588
Well, I just wrote a very simple script that add automatically the current repo to the search box (works with TemperMonkey, and should work with GreaseMonkey) :
// ==UserScript==
// @name Github Current Repo Search
// @namespace http://www.byscripts.info/
// @version 0.1
// @description Add automatically the current repo in the search box
// @match https://github.com/*
// @exclude https://github.com/search*
// @copyright 2012+, ByScripts
// ==/UserScript==
var repo = window.location.pathname.substring(1).split('/').slice(0, 2).join('/');
if(repo.length) {
document.getElementById('command-bar').value = "repo:" + repo;
}
Upvotes: 2
Reputation: 712
It would seem that in private repositories a second search bar labeled "Search source code…" appears. In this case simply hitting Tab
twice will bring you there and let you search inside.
This seems not to appear on public repositories I sampled.
Upvotes: 4