mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Use a checkbox instead of separate entries
This commit is contained in:
parent
3596a77b34
commit
5bb3d724c0
7 changed files with 57 additions and 58 deletions
|
|
@ -7,6 +7,7 @@
|
|||
<system:String x:Key="flowlauncher_plugin_cmd_press_any_key_to_close">Press any key to close this window...</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_leave_cmd_open">Do not close Command Prompt after command execution</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_always_run_as_administrator">Always run as administrator</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_use_windows_terminal">Use Windows Terminal</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_run_as_different_user">Run as different user</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_plugin_name">Shell</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_plugin_description">Allows to execute system commands from Flow Launcher</system:String>
|
||||
|
|
@ -15,4 +16,4 @@
|
|||
<system:String x:Key="flowlauncher_plugin_cmd_run_as_administrator">Run As Administrator</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_copy">Copy the command</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_history">Only show number of most used commands:</system:String>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
<system:String x:Key="flowlauncher_plugin_cmd_press_any_key_to_close">Press any key to close this window...</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_leave_cmd_open">No cerrar Símbolo del Sistema tras ejecutar el comando</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_always_run_as_administrator">Siempre ejecutar como administrador</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_always_use_windows_terminal">Ejecutar en la Terminal de Windows</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_run_as_different_user">Ejecutar como otro usuario</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_plugin_name">Shell</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_plugin_description">Allows to execute system commands from Flow Launcher</system:String>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
<system:String x:Key="flowlauncher_plugin_cmd_press_any_key_to_close">Pulsar cualquier tecla para cerrar esta ventana...</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_leave_cmd_open">No cerrar el símbolo del sistema después de la ejecución del comando</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_always_run_as_administrator">Ejecutar siempre como administrador</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_always_use_windows_terminal">Ejecutar en la Terminal de Windows</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_run_as_different_user">Ejecutar como usuario diferente</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_plugin_name">Terminal</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_cmd_plugin_description">Permite ejecutar comandos del sistema desde Flow Launcher</system:String>
|
||||
|
|
|
|||
|
|
@ -202,28 +202,31 @@ namespace Flow.Launcher.Plugin.Shell
|
|||
{
|
||||
case Shell.Cmd:
|
||||
{
|
||||
info.FileName = "cmd.exe";
|
||||
info.Arguments = $"{(_settings.LeaveShellOpen ? "/k" : "/c")} {command} {(_settings.CloseShellAfterPress ? $"&& echo {context.API.GetTranslation("flowlauncher_plugin_cmd_press_any_key_to_close")} && pause > nul /c" : "")}";
|
||||
|
||||
//// Use info.Arguments instead of info.ArgumentList to enable users better control over the arguments they are writing.
|
||||
//// Previous code using ArgumentList, commands needed to be separated correctly:
|
||||
//// Incorrect:
|
||||
// info.ArgumentList.Add(_settings.LeaveShellOpen ? "/k" : "/c");
|
||||
// info.ArgumentList.Add(command); //<== info.ArgumentList.Add("mkdir \"c:\\test new\"");
|
||||
|
||||
//// Correct version should be:
|
||||
//info.ArgumentList.Add(_settings.LeaveShellOpen ? "/k" : "/c");
|
||||
//info.ArgumentList.Add("mkdir");
|
||||
//info.ArgumentList.Add(@"c:\test new");
|
||||
|
||||
//https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processstartinfo.argumentlist?view=net-6.0#remarks
|
||||
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;
|
||||
}
|
||||
|
||||
case Shell.Powershell:
|
||||
{
|
||||
info.FileName = "powershell.exe";
|
||||
if (_settings.UseWindowsTerminal)
|
||||
{
|
||||
info.FileName = "wt.exe";
|
||||
info.ArgumentList.Add("powershell");
|
||||
}
|
||||
else
|
||||
{
|
||||
info.FileName = "powershell.exe";
|
||||
}
|
||||
if (_settings.LeaveShellOpen)
|
||||
{
|
||||
info.ArgumentList.Add("-NoExit");
|
||||
|
|
@ -232,21 +235,28 @@ namespace Flow.Launcher.Plugin.Shell
|
|||
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" : "")}");
|
||||
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:
|
||||
{
|
||||
info.FileName = "pwsh.exe";
|
||||
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}; {(_settings.CloseShellAfterPress ? $"Write-Host '{context.API.GetTranslation("flowlauncher_plugin_cmd_press_any_key_to_close")}'; [System.Console]::ReadKey(); exit" : "")}");
|
||||
|
||||
info.ArgumentList.Add($"{command}\\; {(_settings.CloseShellAfterPress ? $"Write-Host '{context.API.GetTranslation("flowlauncher_plugin_cmd_press_any_key_to_close")}'\\; [System.Console]::ReadKey()\\; exit" : "")}");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -279,33 +289,6 @@ namespace Flow.Launcher.Plugin.Shell
|
|||
|
||||
break;
|
||||
}
|
||||
case Shell.TerminalPWSH:
|
||||
{
|
||||
info.FileName = "wt.exe";
|
||||
info.ArgumentList.Add("pwsh");
|
||||
if (_settings.LeaveShellOpen)
|
||||
{
|
||||
info.ArgumentList.Add("-NoExit");
|
||||
}
|
||||
info.ArgumentList.Add("-Command");
|
||||
info.ArgumentList.Add(command);
|
||||
break;
|
||||
}
|
||||
case Shell.TerminalCMD:
|
||||
{
|
||||
info.FileName = "wt.exe";
|
||||
info.ArgumentList.Add("cmd");
|
||||
if (_settings.LeaveShellOpen)
|
||||
{
|
||||
info.ArgumentList.Add("/k");
|
||||
}
|
||||
else
|
||||
{
|
||||
info.ArgumentList.Add("/c");
|
||||
}
|
||||
info.ArgumentList.Add(command);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ namespace Flow.Launcher.Plugin.Shell
|
|||
|
||||
public bool RunAsAdministrator { get; set; } = true;
|
||||
|
||||
public bool UseWindowsTerminal { get; set; } = false;
|
||||
|
||||
public bool ShowOnlyMostUsedCMDs { get; set; }
|
||||
|
||||
public int ShowOnlyMostUsedCMDsNumber { get; set; }
|
||||
|
|
@ -39,7 +41,5 @@ namespace Flow.Launcher.Plugin.Shell
|
|||
Powershell = 1,
|
||||
RunCommand = 2,
|
||||
Pwsh = 3,
|
||||
TerminalPWSH = 4,
|
||||
TerminalCMD = 5,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<CheckBox
|
||||
x:Name="ReplaceWinR"
|
||||
|
|
@ -41,19 +42,23 @@
|
|||
Margin="10,5,5,5"
|
||||
HorizontalAlignment="Left"
|
||||
Content="{DynamicResource flowlauncher_plugin_cmd_always_run_as_administrator}" />
|
||||
<CheckBox
|
||||
x:Name="UseWindowsTerminal"
|
||||
Grid.Row="4"
|
||||
Margin="10,5,5,5"
|
||||
HorizontalAlignment="Left"
|
||||
Content="{DynamicResource flowlauncher_plugin_cmd_use_windows_terminal}" />
|
||||
<ComboBox
|
||||
x:Name="ShellComboBox"
|
||||
Grid.Row="4"
|
||||
Grid.Row="5"
|
||||
Margin="10,5,5,5"
|
||||
HorizontalAlignment="Left">
|
||||
<ComboBoxItem>CMD</ComboBoxItem>
|
||||
<ComboBoxItem>PowerShell</ComboBoxItem>
|
||||
<ComboBoxItem>Pwsh</ComboBoxItem>
|
||||
<ComboBoxItem>Terminal (Pwsh)</ComboBoxItem>
|
||||
<ComboBoxItem>Terminal (CMD)</ComboBoxItem>
|
||||
<ComboBoxItem>RunCommand</ComboBoxItem>
|
||||
</ComboBox>
|
||||
<StackPanel Grid.Row="5" Orientation="Horizontal">
|
||||
<StackPanel Grid.Row="6" Orientation="Horizontal">
|
||||
<CheckBox
|
||||
x:Name="ShowOnlyMostUsedCMDs"
|
||||
Margin="10,5,5,5"
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ namespace Flow.Launcher.Plugin.Shell
|
|||
LeaveShellOpen.IsChecked = _settings.LeaveShellOpen;
|
||||
|
||||
AlwaysRunAsAdministrator.IsChecked = _settings.RunAsAdministrator;
|
||||
|
||||
UseWindowsTerminal.IsChecked = _settings.UseWindowsTerminal;
|
||||
|
||||
LeaveShellOpen.IsEnabled = _settings.Shell != Shell.RunCommand;
|
||||
|
||||
|
|
@ -76,6 +78,16 @@ namespace Flow.Launcher.Plugin.Shell
|
|||
_settings.RunAsAdministrator = false;
|
||||
};
|
||||
|
||||
UseWindowsTerminal.Checked += (o, e) =>
|
||||
{
|
||||
_settings.UseWindowsTerminal = true;
|
||||
};
|
||||
|
||||
UseWindowsTerminal.Unchecked += (o, e) =>
|
||||
{
|
||||
_settings.UseWindowsTerminal = false;
|
||||
};
|
||||
|
||||
ReplaceWinR.Checked += (o, e) =>
|
||||
{
|
||||
_settings.ReplaceWinR = true;
|
||||
|
|
@ -91,8 +103,6 @@ namespace Flow.Launcher.Plugin.Shell
|
|||
Shell.Cmd => 0,
|
||||
Shell.Powershell => 1,
|
||||
Shell.Pwsh => 2,
|
||||
Shell.TerminalPWSH => 3,
|
||||
Shell.TerminalCMD => 4,
|
||||
_ => ShellComboBox.Items.Count - 1
|
||||
};
|
||||
|
||||
|
|
@ -103,8 +113,6 @@ namespace Flow.Launcher.Plugin.Shell
|
|||
0 => Shell.Cmd,
|
||||
1 => Shell.Powershell,
|
||||
2 => Shell.Pwsh,
|
||||
3 => Shell.TerminalPWSH,
|
||||
4 => Shell.TerminalCMD,
|
||||
_ => Shell.RunCommand
|
||||
};
|
||||
LeaveShellOpen.IsEnabled = _settings.Shell != Shell.RunCommand;
|
||||
|
|
|
|||
Loading…
Reference in a new issue