diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs index cdd15fd3d..1aaf2f843 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs @@ -41,8 +41,10 @@ namespace Flow.Launcher.Plugin.Explorer contextMenus.Add(CreateOpenWithEditorResult(record)); if (record.Type == ResultType.Folder && record.WindowsIndexed) + { contextMenus.Add(CreateAddToIndexSearchExclusionListResult(record)); - + contextMenus.Add(CreateOpenWithShellResult(record)); + } contextMenus.Add(CreateOpenContainingFolderResult(record)); contextMenus.Add(CreateOpenWindowsIndexingOptions()); @@ -246,12 +248,13 @@ namespace Flow.Launcher.Plugin.Explorer }; } + + private Result CreateOpenWithEditorResult(SearchResult record) { string editorPath = Settings.EditorPath; - var name = Context.API.GetTranslation("plugin_explorer_openwitheditor") - + " " + Path.GetFileNameWithoutExtension(editorPath); + var name = $"{Context.API.GetTranslation("plugin_explorer_openwitheditor")} {Path.GetFileNameWithoutExtension(editorPath)}"; return new Result { @@ -274,6 +277,38 @@ namespace Flow.Launcher.Plugin.Explorer IcoPath = Constants.FileImagePath }; } + + private Result CreateOpenWithShellResult(SearchResult record) + { + string shellPath = Settings.ShellPath; + + var name = $"{Context.API.GetTranslation("plugin_explorer_openwithshell")} {Path.GetFileNameWithoutExtension(shellPath)}"; + + return new Result + { + Title = name, + Action = _ => + { + try + { + Process.Start(new ProcessStartInfo() + { + FileName = shellPath, + WorkingDirectory = record.FullPath + }); + return true; + } + catch (Exception e) + { + var message = $"Failed to open editor for file at {record.FullPath} with Shell {Path.GetFileNameWithoutExtension(shellPath)} at {shellPath}"; + LogException(message, e); + Context.API.ShowMsgError(message); + return false; + } + }, + IcoPath = Constants.FileImagePath + }; + } private Result CreateAddToIndexSearchExclusionListResult(SearchResult record) { diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index 691d61ffe..2a0349ac8 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -28,6 +28,7 @@ Sort Option: Launch Hidden Editor Path + Shell Path Index Search Excluded Paths Use search result's location as executable working directory Use Index Search For Path Search @@ -62,6 +63,7 @@ Open containing folder Opens the location that contains the file or folder Open With Editor: + Open With Shell: Exclude current and sub-directories from Index Search Excluded from Index Search Open Windows Indexing Options diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs index 33df7b562..c1e1ea8b9 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs @@ -25,6 +25,8 @@ namespace Flow.Launcher.Plugin.Explorer public string EditorPath { get; set; } = ""; + public string ShellPath { get; set; } = "cmd"; + public bool UseLocationAsWorkingDir { get; set; } = false; diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs index 08f25cd51..11aff92f4 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs @@ -314,7 +314,10 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels get => Settings.UseWindowsIndexForDirectorySearch; set => Settings.UseWindowsIndexForDirectorySearch = value; } - public ICommand OpenEditorPath => new RelayCommand(_ => + + private ICommand _openEditorPathCommand; + + public ICommand OpenEditorPath => _openEditorPathCommand ??= new RelayCommand(_ => { var path = PromptUserSelectPath(ResultType.File, Settings.EditorPath != null ? Path.GetDirectoryName(Settings.EditorPath) : null); if (path is null) @@ -323,6 +326,18 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels EditorPath = path; }); + private ICommand _openShellPathCommand; + + public ICommand OpenShellPath => _openShellPathCommand ??= new RelayCommand(_ => + { + var path = PromptUserSelectPath(ResultType.File, Settings.EditorPath != null ? Path.GetDirectoryName(Settings.EditorPath) : null); + if (path is null) + return; + + ShellPath = path; + }); + + public string EditorPath { get => Settings.EditorPath; @@ -333,6 +348,16 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels } } + public string ShellPath + { + get => Settings.ShellPath; + set + { + Settings.ShellPath = value; + OnPropertyChanged(); + } + } + #region Everything FastSortWarning diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml index bbc25a597..f9e37c1c2 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml @@ -109,6 +109,26 @@ Command="{Binding OpenEditorPath}" Content="..." /> + + + +