diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Assets/Peek.png b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Assets/Peek.png
new file mode 100644
index 0000000000..3beeccaf17
Binary files /dev/null and b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Assets/Peek.png differ
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Commands/PeekFileCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Commands/PeekFileCommand.cs
new file mode 100644
index 0000000000..808daa567f
--- /dev/null
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Commands/PeekFileCommand.cs
@@ -0,0 +1,73 @@
+// Copyright (c) Microsoft Corporation
+// The Microsoft Corporation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Diagnostics;
+using System.IO;
+using ManagedCommon;
+using Microsoft.CmdPal.Ext.Indexer.Properties;
+using Microsoft.CommandPalette.Extensions.Toolkit;
+
+namespace Microsoft.CmdPal.Ext.Indexer.Commands;
+
+///
+/// Command to preview a file using PowerToys Peek.
+///
+public sealed partial class PeekFileCommand : InvokableCommand
+{
+ private const string PeekExecutable = @"WinUI3Apps\PowerToys.Peek.UI.exe";
+
+ private static readonly Lazy _peekPath = new(GetPeekExecutablePath);
+
+ private readonly string _fullPath;
+
+ public PeekFileCommand(string fullPath)
+ {
+ _fullPath = fullPath;
+ Name = Resources.Indexer_Command_Peek;
+ Icon = Icons.PeekIcon;
+ }
+
+ ///
+ /// Gets a value indicating whether Peek is available on this system.
+ ///
+ public static bool IsPeekAvailable => !string.IsNullOrEmpty(_peekPath.Value);
+
+ public override CommandResult Invoke()
+ {
+ var peekExe = _peekPath.Value;
+ if (string.IsNullOrEmpty(peekExe))
+ {
+ return CommandResult.ShowToast(Resources.Indexer_Command_Peek_NotAvailable);
+ }
+
+ try
+ {
+ using var process = new Process();
+ process.StartInfo.FileName = peekExe;
+ process.StartInfo.Arguments = $"\"{_fullPath}\"";
+ process.StartInfo.UseShellExecute = false;
+ process.Start();
+ }
+ catch (Exception ex)
+ {
+ ExtensionHost.LogMessage($"Unable to launch Peek for {_fullPath}\n{ex}");
+ return CommandResult.ShowToast(Resources.Indexer_Command_Peek_Failed);
+ }
+
+ return CommandResult.Dismiss();
+ }
+
+ private static string GetPeekExecutablePath()
+ {
+ var installPath = PowerToysPathResolver.GetPowerToysInstallPath();
+ if (string.IsNullOrEmpty(installPath))
+ {
+ return string.Empty;
+ }
+
+ var peekPath = Path.Combine(installPath, PeekExecutable);
+ return File.Exists(peekPath) ? peekPath : string.Empty;
+ }
+}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Data/IndexerListItem.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Data/IndexerListItem.cs
index 51a30ddc86..54d2744abd 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Data/IndexerListItem.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Data/IndexerListItem.cs
@@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.CmdPal.Core.Common.Commands;
+using Microsoft.CmdPal.Ext.Indexer.Commands;
using Microsoft.CmdPal.Ext.Indexer.Helpers;
using Microsoft.CmdPal.Ext.Indexer.Pages;
using Microsoft.CmdPal.Ext.Indexer.Properties;
@@ -96,6 +97,13 @@ internal sealed partial class IndexerListItem : ListItem
}
commands.Add(new CommandContextItem(new OpenWithCommand(fullPath)));
+
+ // Add Peek command if available (only for files, not directories)
+ if (!isDir && PeekFileCommand.IsPeekAvailable)
+ {
+ commands.Add(new CommandContextItem(new PeekFileCommand(fullPath)) { RequestedShortcut = KeyChords.Peek });
+ }
+
commands.Add(new CommandContextItem(new ShowFileInFolderCommand(fullPath) { Name = Resources.Indexer_Command_ShowInFolder }) { RequestedShortcut = KeyChords.OpenFileLocation });
commands.Add(new CommandContextItem(new CopyPathCommand(fullPath) { Name = Resources.Indexer_Command_CopyPath }) { RequestedShortcut = KeyChords.CopyFilePath });
commands.Add(new CommandContextItem(new OpenInConsoleCommand(fullPath)) { RequestedShortcut = KeyChords.OpenInConsole });
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Icons.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Icons.cs
index bd9759514c..1e92d9f323 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Icons.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Icons.cs
@@ -23,4 +23,6 @@ internal static class Icons
internal static IconInfo FilesIcon { get; } = new("\uF571"); // PrintAllPages
internal static IconInfo FilterIcon { get; } = new("\uE71C"); // Filter
+
+ internal static IconInfo PeekIcon { get; } = IconHelpers.FromRelativePath("Assets\\Peek.png");
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/KeyChords.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/KeyChords.cs
index c0fd69d0f2..aa44696a7b 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/KeyChords.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/KeyChords.cs
@@ -4,6 +4,8 @@
using Microsoft.CmdPal.Core.Common.Helpers;
using Microsoft.CommandPalette.Extensions;
+using Microsoft.CommandPalette.Extensions.Toolkit;
+using Windows.System;
namespace Microsoft.CmdPal.Ext.Indexer;
@@ -14,4 +16,6 @@ internal static class KeyChords
internal static KeyChord CopyFilePath { get; } = WellKnownKeyChords.CopyFilePath;
internal static KeyChord OpenInConsole { get; } = WellKnownKeyChords.OpenInConsole;
+
+ internal static KeyChord Peek { get; } = KeyChordHelpers.FromModifiers(ctrl: true, vkey: (int)VirtualKey.Space);
}
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Microsoft.CmdPal.Ext.Indexer.csproj b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Microsoft.CmdPal.Ext.Indexer.csproj
index 6b3b304825..2c40afd19c 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Microsoft.CmdPal.Ext.Indexer.csproj
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Microsoft.CmdPal.Ext.Indexer.csproj
@@ -42,6 +42,9 @@
PreserveNewest
+
+ PreserveNewest
+
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Properties/Resources.Designer.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Properties/Resources.Designer.cs
index 4394cd6697..469c5faf61 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Properties/Resources.Designer.cs
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Properties/Resources.Designer.cs
@@ -132,6 +132,33 @@ namespace Microsoft.CmdPal.Ext.Indexer.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Peek preview.
+ ///
+ internal static string Indexer_Command_Peek {
+ get {
+ return ResourceManager.GetString("Indexer_Command_Peek", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Failed to launch Peek.
+ ///
+ internal static string Indexer_Command_Peek_Failed {
+ get {
+ return ResourceManager.GetString("Indexer_Command_Peek_Failed", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to PowerToys Peek is not available.
+ ///
+ internal static string Indexer_Command_Peek_NotAvailable {
+ get {
+ return ResourceManager.GetString("Indexer_Command_Peek_NotAvailable", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Search all files.
///
diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Properties/Resources.resx b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Properties/Resources.resx
index 9ea1c4563e..8f5f760137 100644
--- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Properties/Resources.resx
+++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Indexer/Properties/Resources.resx
@@ -202,4 +202,13 @@ You can try searching all files on this PC or adjust your indexing settings.
Files
+
+ Peek preview
+
+
+ PowerToys Peek is not available
+
+
+ Failed to launch Peek
+
\ No newline at end of file