mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Apply for all wt.exe
This commit is contained in:
parent
b2e754dfd5
commit
d7c7ec8f5e
1 changed files with 74 additions and 70 deletions
|
|
@ -201,97 +201,101 @@ namespace Flow.Launcher.Plugin.Shell
|
|||
switch (_settings.Shell)
|
||||
{
|
||||
case Shell.Cmd:
|
||||
{
|
||||
if (_settings.UseWindowsTerminal)
|
||||
{
|
||||
info.FileName = "wt.exe";
|
||||
info.ArgumentList.Add("cmd");
|
||||
}
|
||||
else
|
||||
{
|
||||
info.FileName = "cmd.exe";
|
||||
}
|
||||
if (_settings.UseWindowsTerminal)
|
||||
{
|
||||
info.FileName = "wt.exe";
|
||||
info.ArgumentList.Add("cmd");
|
||||
}
|
||||
else
|
||||
{
|
||||
info.FileName = "cmd.exe";
|
||||
}
|
||||
|
||||
info.ArgumentList.Add($"{(_settings.LeaveShellOpen ? "/k" : "/c")} {command} {(_settings.CloseShellAfterPress ? $"&& echo {Context.API.GetTranslation("flowlauncher_plugin_cmd_press_any_key_to_close")} && pause > nul /c" : "")}");
|
||||
break;
|
||||
}
|
||||
info.ArgumentList.Add($"{(_settings.LeaveShellOpen ? "/k" : "/c")} {command} {(_settings.CloseShellAfterPress ? $"&& echo {Context.API.GetTranslation("flowlauncher_plugin_cmd_press_any_key_to_close")} && pause > nul /c" : "")}");
|
||||
break;
|
||||
}
|
||||
|
||||
case Shell.Powershell:
|
||||
{
|
||||
if (_settings.UseWindowsTerminal)
|
||||
{
|
||||
info.FileName = "wt.exe";
|
||||
info.ArgumentList.Add("powershell");
|
||||
// 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";
|
||||
info.ArgumentList.Add("powershell");
|
||||
}
|
||||
else
|
||||
{
|
||||
info.FileName = "powershell.exe";
|
||||
}
|
||||
if (_settings.LeaveShellOpen)
|
||||
{
|
||||
info.ArgumentList.Add("-NoExit");
|
||||
info.ArgumentList.Add(command);
|
||||
}
|
||||
else
|
||||
{
|
||||
info.ArgumentList.Add("-Command");
|
||||
info.ArgumentList.Add($"{command}{addedCharacter}; {(_settings.CloseShellAfterPress ? $"Write-Host '{Context.API.GetTranslation("flowlauncher_plugin_cmd_press_any_key_to_close")}'{addedCharacter}; [System.Console]::ReadKey(){addedCharacter}; exit" : "")}");
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
info.FileName = "powershell.exe";
|
||||
}
|
||||
if (_settings.LeaveShellOpen)
|
||||
{
|
||||
info.ArgumentList.Add("-NoExit");
|
||||
info.ArgumentList.Add(command);
|
||||
}
|
||||
else
|
||||
{
|
||||
info.ArgumentList.Add("-Command");
|
||||
info.ArgumentList.Add($"{command}\\; {(_settings.CloseShellAfterPress ? $"Write-Host '{Context.API.GetTranslation("flowlauncher_plugin_cmd_press_any_key_to_close")}'\\; [System.Console]::ReadKey()\\; exit" : "")}");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case Shell.Pwsh:
|
||||
{
|
||||
// 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";
|
||||
info.ArgumentList.Add("pwsh");
|
||||
// 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";
|
||||
info.ArgumentList.Add("pwsh");
|
||||
}
|
||||
else
|
||||
{
|
||||
info.FileName = "pwsh.exe";
|
||||
}
|
||||
if (_settings.LeaveShellOpen)
|
||||
{
|
||||
info.ArgumentList.Add("-NoExit");
|
||||
}
|
||||
info.ArgumentList.Add("-Command");
|
||||
info.ArgumentList.Add($"{command}{addedCharacter}; {(_settings.CloseShellAfterPress ? $"Write-Host '{Context.API.GetTranslation("flowlauncher_plugin_cmd_press_any_key_to_close")}'{addedCharacter}; [System.Console]::ReadKey(){addedCharacter}; exit" : "")}");
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
info.FileName = "pwsh.exe";
|
||||
}
|
||||
if (_settings.LeaveShellOpen)
|
||||
{
|
||||
info.ArgumentList.Add("-NoExit");
|
||||
}
|
||||
info.ArgumentList.Add("-Command");
|
||||
info.ArgumentList.Add($"{command}{addedCharacter}; {(_settings.CloseShellAfterPress ? $"Write-Host '{Context.API.GetTranslation("flowlauncher_plugin_cmd_press_any_key_to_close")}'\\; [System.Console]::ReadKey()\\; exit" : "")}");
|
||||
break;
|
||||
}
|
||||
|
||||
case Shell.RunCommand:
|
||||
{
|
||||
var parts = command.Split(new[]
|
||||
{
|
||||
' '
|
||||
}, 2);
|
||||
if (parts.Length == 2)
|
||||
{
|
||||
var filename = parts[0];
|
||||
if (ExistInPath(filename))
|
||||
var parts = command.Split(new[]
|
||||
{
|
||||
var arguments = parts[1];
|
||||
info.FileName = filename;
|
||||
info.ArgumentList.Add(arguments);
|
||||
' '
|
||||
}, 2);
|
||||
if (parts.Length == 2)
|
||||
{
|
||||
var filename = parts[0];
|
||||
if (ExistInPath(filename))
|
||||
{
|
||||
var arguments = parts[1];
|
||||
info.FileName = filename;
|
||||
info.ArgumentList.Add(arguments);
|
||||
}
|
||||
else
|
||||
{
|
||||
info.FileName = command;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
info.FileName = command;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
info.FileName = command;
|
||||
|
||||
info.UseShellExecute = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
info.UseShellExecute = true;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue