From 89214fb58a0844854a99fcd8ac35a185436caa6d Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 16 Jun 2025 12:38:31 +0800 Subject: [PATCH] Improve code quality --- Plugins/Flow.Launcher.Plugin.Shell/Main.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs index 37f382ad1..a51aadec7 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs @@ -200,6 +200,7 @@ namespace Flow.Launcher.Plugin.Shell WorkingDirectory = workingDirectory, }; var notifyStr = Context.API.GetTranslation("flowlauncher_plugin_cmd_press_any_key_to_close"); + var addedCharacter = _settings.UseWindowsTerminal ? "\\" : ""; switch (_settings.Shell) { case Shell.Cmd: @@ -213,9 +214,16 @@ namespace Flow.Launcher.Plugin.Shell { info.FileName = "cmd.exe"; } - + if (_settings.LeaveShellOpen) + { + info.ArgumentList.Add("/k"); + } + else + { + info.ArgumentList.Add("/c"); + } info.ArgumentList.Add( - $"{(_settings.LeaveShellOpen ? "/k" : "/c")} {command}" + + $"{command}" + $"{(_settings.CloseShellAfterPress ? $" && echo {notifyStr} && pause > nul /c" : "")}"); @@ -226,7 +234,6 @@ namespace Flow.Launcher.Plugin.Shell { // Using just a ; doesn't work with wt, as it's used to create a new tab for the terminal window // \\ must be escaped for it to work properly, or breaking it into multiple arguments - var addedCharacter = _settings.UseWindowsTerminal ? "\\" : ""; if (_settings.UseWindowsTerminal) { info.FileName = "wt.exe"; @@ -257,7 +264,6 @@ namespace Flow.Launcher.Plugin.Shell { // Using just a ; doesn't work with wt, as it's used to create a new tab for the terminal window // \\ must be escaped for it to work properly, or breaking it into multiple arguments - var addedCharacter = _settings.UseWindowsTerminal ? "\\" : ""; if (_settings.UseWindowsTerminal) { info.FileName = "wt.exe";