mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
[PTRun][Shell]Shell selection and combobox improvements (#28972)
* Make combobox items sortable * Update plugin settings * settings description * fix settings hang on outdated plugin code * spell fixes, shell implementation, translation improvements * rename property * backward compatibility * comment changes * comment changes * review feedback 1 * review feedback 2 * Code clean up
This commit is contained in:
@@ -43,24 +43,28 @@ namespace Microsoft.Plugin.Shell
|
||||
{
|
||||
new PluginAdditionalOption()
|
||||
{
|
||||
Key = "LeaveShellOpen",
|
||||
DisplayLabel = Resources.wox_leave_shell_open,
|
||||
Value = _settings.LeaveShellOpen,
|
||||
Key = "ShellCommandExecution",
|
||||
DisplayLabel = Resources.wox_shell_command_execution,
|
||||
DisplayDescription = Resources.wox_shell_command_execution_description,
|
||||
PluginOptionType = PluginAdditionalOption.AdditionalOptionType.Combobox,
|
||||
ComboBoxItems = new List<KeyValuePair<string, string>>
|
||||
{
|
||||
new KeyValuePair<string, string>(Resources.find_executable_file_and_run_it, "2"),
|
||||
new KeyValuePair<string, string>(Resources.run_command_in_command_prompt, "0"),
|
||||
new KeyValuePair<string, string>(Resources.run_command_in_powershell, "1"),
|
||||
new KeyValuePair<string, string>(Resources.run_command_in_powershell_seven, "6"),
|
||||
new KeyValuePair<string, string>(Resources.run_command_in_windows_terminal_cmd, "5"),
|
||||
new KeyValuePair<string, string>(Resources.run_command_in_windows_terminal_powershell, "3"),
|
||||
new KeyValuePair<string, string>(Resources.run_command_in_windows_terminal_powershell_seven, "4"),
|
||||
},
|
||||
ComboBoxValue = (int)_settings.Shell,
|
||||
},
|
||||
|
||||
new PluginAdditionalOption()
|
||||
{
|
||||
Key = "ShellCommandExecution",
|
||||
DisplayLabel = Resources.wox_shell_command_execution,
|
||||
PluginOptionType = PluginAdditionalOption.AdditionalOptionType.Combobox,
|
||||
ComboBoxOptions = new List<string>
|
||||
{
|
||||
Resources.run_command_in_command_prompt,
|
||||
Resources.run_command_in_powershell,
|
||||
Resources.find_executable_file_and_run_it,
|
||||
Resources.run_command_in_windows_terminal,
|
||||
},
|
||||
ComboBoxValue = (int)_settings.Shell,
|
||||
Key = "LeaveShellOpen",
|
||||
DisplayLabel = Resources.wox_leave_shell_open,
|
||||
Value = _settings.LeaveShellOpen,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -212,21 +216,63 @@ namespace Microsoft.Plugin.Shell
|
||||
}
|
||||
else
|
||||
{
|
||||
arguments = $"\"{command} ; Read-Host -Prompt \\\"Press Enter to continue\\\"\"";
|
||||
arguments = $"\"{command} ; Read-Host -Prompt \\\"{Resources.run_plugin_cmd_wait_message}\\\"\"";
|
||||
}
|
||||
|
||||
info = ShellCommand.SetProcessStartInfo("powershell.exe", workingDirectory, arguments, runAsVerbArg);
|
||||
}
|
||||
else if (_settings.Shell == ExecutionShell.WindowsTerminal)
|
||||
else if (_settings.Shell == ExecutionShell.PowerShellSeven)
|
||||
{
|
||||
string arguments;
|
||||
if (_settings.LeaveShellOpen)
|
||||
{
|
||||
arguments = $"powershell -NoExit \"{command}\"";
|
||||
arguments = $"-NoExit -C \"{command}\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
arguments = $"powershell \"{command}\"";
|
||||
arguments = $"-C \"{command} ; Read-Host -Prompt \\\"{Resources.run_plugin_cmd_wait_message}\\\"\"";
|
||||
}
|
||||
|
||||
info = ShellCommand.SetProcessStartInfo("pwsh.exe", workingDirectory, arguments, runAsVerbArg);
|
||||
}
|
||||
else if (_settings.Shell == ExecutionShell.WindowsTerminalCmd)
|
||||
{
|
||||
string arguments;
|
||||
if (_settings.LeaveShellOpen)
|
||||
{
|
||||
arguments = $"cmd.exe /k \"{command}\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
arguments = $"cmd.exe /c \"{command}\" & pause";
|
||||
}
|
||||
|
||||
info = ShellCommand.SetProcessStartInfo("wt.exe", workingDirectory, arguments, runAsVerbArg);
|
||||
}
|
||||
else if (_settings.Shell == ExecutionShell.WindowsTerminalPowerShell)
|
||||
{
|
||||
string arguments;
|
||||
if (_settings.LeaveShellOpen)
|
||||
{
|
||||
arguments = $"powershell -NoExit -C \"{command}\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
arguments = $"powershell -C \"{command}\"";
|
||||
}
|
||||
|
||||
info = ShellCommand.SetProcessStartInfo("wt.exe", workingDirectory, arguments, runAsVerbArg);
|
||||
}
|
||||
else if (_settings.Shell == ExecutionShell.WindowsTerminalPowerShellSeven)
|
||||
{
|
||||
string arguments;
|
||||
if (_settings.LeaveShellOpen)
|
||||
{
|
||||
arguments = $"pwsh.exe -NoExit -C \"{command}\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
arguments = $"pwsh.exe -C \"{command}\"";
|
||||
}
|
||||
|
||||
info = ShellCommand.SetProcessStartInfo("wt.exe", workingDirectory, arguments, runAsVerbArg);
|
||||
|
||||
Reference in New Issue
Block a user