在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開啟。效果如下圖:

//判斷是否為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!!!
關注公眾號,我開發的開源工具分享給你!