我知道可以通过在搜索框中输入来搜索仓库中的代码:
my-keyword repo:user_name/repository_name
但是因为我每天都在使用很多项目,并且喜欢深入了解源代码以了解这个或那个是如何工作的,所以每次我必须输入repo: user_name/repository_name
部分很快就会变得烦人想要搜索一些东西。
有没有办法在当前查看的repo源代码中快速搜索代码?
如果我目前使用frankenstein/monster
回购,我希望能够搜索create_life
方法,而无需在搜索框中输入repo: frankenstein/monster
,因为我是已经在这个回购中。
(就像你在文本编辑器中处理文件一样,按Ctrl + F并需要输入当前文件的文件名)
答案 0 :(得分:3)
2013年5月更新:请参阅“ Repository Search on all Repositories ”
今天我们允许您搜索自己的公共存储库以及您有权访问的任何私有存储库。
当您在存储库页面上时,您会看到默认情况下您正在搜索该存储库的指示:
原始答案(2013年2月)
我没有找到任何“repo:current
”或其他约定来为“代码”搜索指定默认回购。
我通常在单独的窗口中进行搜索,选择“代码”并填写“repo:username/reponame
”。
我只添加了我需要的关键字,然后点击回车。
我多次重复此过程,只更改关键字,但如果感兴趣的结果,我会在另一个标签中打开它,以保留搜索页面及其字段。
答案 1 :(得分:3)
在私人存储库中,似乎会出现标有“搜索源代码...”的第二个搜索栏。在这种情况下,只需按两次Tab
即可将您带到那里并让您在里面搜索。
这似乎没有出现在我采样的公共存储库中。
答案 2 :(得分:2)
好吧,我刚刚编写了一个非常简单的脚本,可以自动将当前的repo添加到搜索框中(与TemperMonkey一起使用,并且可以使用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;
}
答案 3 :(得分:0)