在mac系统除了自带的Spotlight还有一个很好用的工具叫Alfred

在windows系统也有一个很好用的工具叫PowerToys,是微软的一个开源项目

https://github.com/microsoft/PowerToys
从上面的github地址可以下载安装包。

它有很多快捷功能,请大家自己研究吧。今天要说的是PowerToys Run

默认的唤起快捷键是 Alt+Space
但是PowerToys Run有一个问题,就是自带的文件搜索功能是基于系统索引的,搜索的速度慢,还经常找不到我想要找的文件。看见很多人在Issue里面提希望能支持Everything搜索,官方说有社区提供了插件了 https://github.com/IzaiahSun/PowerToys
从这个大佬的releases里面下载下来

然后定位到zip里的modules\launcher\plugins,将整个Community.PowerToys.Run.Plugin.Everything文件夹复制到系统中已经安装好的PowerToys目录\modules\launcher\Plugins中,最后重启PowerToys即可!
下面才是重点:
PowerToys Run的功能在开始以插件的形式提供之后,想要扩展自己的功能是非常简单的,我们只需要写代码加入自己的逻辑就好了。
因为我经常会用idea,我就写了几行代码来扩展一下,如果是java项目的文件夹,可以直接用idea打开。效果如下图:
image
//判断是否为java工程文件夹
public static bool CanRunIdea(string path)
{
if (File.Exists(path))
{
return path.EndsWith("pom.xml");
}
var buildGradleFile = System.IO.Path.Combine(path, "build.gradle");
if (File.Exists(buildGradleFile))
{
return true;
}
var pomFile = System.IO.Path.Combine(path, "pom.xml");
if (File.Exists(pomFile))
{
return true;
}
return false;
}
//创建运行idea的按钮以及点击按钮事件的触发
private static ContextMenuResult CreateRunIdeaContextMenu(SearchResult record)
{
return new ContextMenuResult
{
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
Title = Properties.Resources.Community_plugin_everything_run_as_idea,
Glyph = "\xEC58",
FontFamily = "Segoe MDL2 Assets",
AcceleratorKey = Key.F1,
AcceleratorModifiers = ModifierKeys.Windows,
Action = _ =>
{
try
{
Task.Run(() => {
var idea = Environment.GetEnvironmentVariable("idea");
if (string.IsNullOrEmpty(idea))
{
RunCommand($"idea \"{record.FullPath}\"", record.FullPath);
}
else
{
RunCommand($"\"{idea}\" \"{record.FullPath}\"", record.FullPath);
}
});
return true;
}
catch (System.Exception e)
{
Log.Exception($"Failed to run {record.FullPath} as idea, {e.Message}", e, MethodBase.GetCurrentMethod().DeclaringType);
return false;
}
},
};
}
代码很简单,如果识别到了是java项目文件夹,就展示一个icon图标按钮,点击用idea打开。
idea的启动path 你可以配置在环境变量里面,

如果你用是Toolsbox的话,idea会经常更新版本,每次升级都得重新改环境变量嫌麻烦,那么Toolsbox的这个功能可以设置下

然后把上图中的Shell脚本的文件夹设置到 环境变量的PATH里面 就一劳永逸了!

想要获取我更改后的EveryThing插件的可以公众号发送文本文字:PowerToys
下载后解压到你本机PowerToys目录
比如我的本机是:
C:\Program Files\PowerToys\modules\launcher\Plugins

Enjoy!!!
关注公众号,我开发的开源工具分享给你!