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_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_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_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_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_name">Shell</system:String>
|
||||||
<system:String x:Key="flowlauncher_plugin_cmd_plugin_description">Allows to execute system commands from Flow Launcher</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_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_copy">Copy the command</system:String>
|
||||||
<system:String x:Key="flowlauncher_plugin_cmd_history">Only show number of most used commands:</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_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_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_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_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_name">Shell</system:String>
|
||||||
<system:String x:Key="flowlauncher_plugin_cmd_plugin_description">Allows to execute system commands from Flow Launcher</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_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_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_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_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_name">Terminal</system:String>
|
||||||
<system:String x:Key="flowlauncher_plugin_cmd_plugin_description">Permite ejecutar comandos del sistema desde Flow Launcher</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:
|
case Shell.Cmd:
|
||||||
{
|
{
|
||||||
info.FileName = "cmd.exe";
|
if (_settings.UseWindowsTerminal)
|
||||||
info.Arguments = $"{(_settings.LeaveShellOpen ? "/k" : "/c")} {command} {(_settings.CloseShellAfterPress ? $"&& echo {context.API.GetTranslation("flowlauncher_plugin_cmd_press_any_key_to_close")} && pause > nul /c" : "")}";
|
{
|
||||||
|
info.FileName = "wt.exe";
|
||||||
//// Use info.Arguments instead of info.ArgumentList to enable users better control over the arguments they are writing.
|
info.ArgumentList.Add("cmd");
|
||||||
//// Previous code using ArgumentList, commands needed to be separated correctly:
|
}
|
||||||
//// Incorrect:
|
else
|
||||||
// info.ArgumentList.Add(_settings.LeaveShellOpen ? "/k" : "/c");
|
{
|
||||||
// info.ArgumentList.Add(command); //<== info.ArgumentList.Add("mkdir \"c:\\test new\"");
|
info.FileName = "cmd.exe";
|
||||||
|
}
|
||||||
//// 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
|
|
||||||
|
|
||||||
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Shell.Powershell:
|
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)
|
if (_settings.LeaveShellOpen)
|
||||||
{
|
{
|
||||||
info.ArgumentList.Add("-NoExit");
|
info.ArgumentList.Add("-NoExit");
|
||||||
|
|
@ -232,21 +235,28 @@ namespace Flow.Launcher.Plugin.Shell
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
info.ArgumentList.Add("-Command");
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Shell.Pwsh:
|
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)
|
if (_settings.LeaveShellOpen)
|
||||||
{
|
{
|
||||||
info.ArgumentList.Add("-NoExit");
|
info.ArgumentList.Add("-NoExit");
|
||||||
}
|
}
|
||||||
info.ArgumentList.Add("-Command");
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -279,33 +289,6 @@ namespace Flow.Launcher.Plugin.Shell
|
||||||
|
|
||||||
break;
|
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:
|
default:
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ namespace Flow.Launcher.Plugin.Shell
|
||||||
|
|
||||||
public bool RunAsAdministrator { get; set; } = true;
|
public bool RunAsAdministrator { get; set; } = true;
|
||||||
|
|
||||||
|
public bool UseWindowsTerminal { get; set; } = false;
|
||||||
|
|
||||||
public bool ShowOnlyMostUsedCMDs { get; set; }
|
public bool ShowOnlyMostUsedCMDs { get; set; }
|
||||||
|
|
||||||
public int ShowOnlyMostUsedCMDsNumber { get; set; }
|
public int ShowOnlyMostUsedCMDsNumber { get; set; }
|
||||||
|
|
@ -39,7 +41,5 @@ namespace Flow.Launcher.Plugin.Shell
|
||||||
Powershell = 1,
|
Powershell = 1,
|
||||||
RunCommand = 2,
|
RunCommand = 2,
|
||||||
Pwsh = 3,
|
Pwsh = 3,
|
||||||
TerminalPWSH = 4,
|
|
||||||
TerminalCMD = 5,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
|
<RowDefinition />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<CheckBox
|
<CheckBox
|
||||||
x:Name="ReplaceWinR"
|
x:Name="ReplaceWinR"
|
||||||
|
|
@ -41,19 +42,23 @@
|
||||||
Margin="10,5,5,5"
|
Margin="10,5,5,5"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Content="{DynamicResource flowlauncher_plugin_cmd_always_run_as_administrator}" />
|
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
|
<ComboBox
|
||||||
x:Name="ShellComboBox"
|
x:Name="ShellComboBox"
|
||||||
Grid.Row="4"
|
Grid.Row="5"
|
||||||
Margin="10,5,5,5"
|
Margin="10,5,5,5"
|
||||||
HorizontalAlignment="Left">
|
HorizontalAlignment="Left">
|
||||||
<ComboBoxItem>CMD</ComboBoxItem>
|
<ComboBoxItem>CMD</ComboBoxItem>
|
||||||
<ComboBoxItem>PowerShell</ComboBoxItem>
|
<ComboBoxItem>PowerShell</ComboBoxItem>
|
||||||
<ComboBoxItem>Pwsh</ComboBoxItem>
|
<ComboBoxItem>Pwsh</ComboBoxItem>
|
||||||
<ComboBoxItem>Terminal (Pwsh)</ComboBoxItem>
|
|
||||||
<ComboBoxItem>Terminal (CMD)</ComboBoxItem>
|
|
||||||
<ComboBoxItem>RunCommand</ComboBoxItem>
|
<ComboBoxItem>RunCommand</ComboBoxItem>
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
<StackPanel Grid.Row="5" Orientation="Horizontal">
|
<StackPanel Grid.Row="6" Orientation="Horizontal">
|
||||||
<CheckBox
|
<CheckBox
|
||||||
x:Name="ShowOnlyMostUsedCMDs"
|
x:Name="ShowOnlyMostUsedCMDs"
|
||||||
Margin="10,5,5,5"
|
Margin="10,5,5,5"
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ namespace Flow.Launcher.Plugin.Shell
|
||||||
LeaveShellOpen.IsChecked = _settings.LeaveShellOpen;
|
LeaveShellOpen.IsChecked = _settings.LeaveShellOpen;
|
||||||
|
|
||||||
AlwaysRunAsAdministrator.IsChecked = _settings.RunAsAdministrator;
|
AlwaysRunAsAdministrator.IsChecked = _settings.RunAsAdministrator;
|
||||||
|
|
||||||
|
UseWindowsTerminal.IsChecked = _settings.UseWindowsTerminal;
|
||||||
|
|
||||||
LeaveShellOpen.IsEnabled = _settings.Shell != Shell.RunCommand;
|
LeaveShellOpen.IsEnabled = _settings.Shell != Shell.RunCommand;
|
||||||
|
|
||||||
|
|
@ -76,6 +78,16 @@ namespace Flow.Launcher.Plugin.Shell
|
||||||
_settings.RunAsAdministrator = false;
|
_settings.RunAsAdministrator = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
UseWindowsTerminal.Checked += (o, e) =>
|
||||||
|
{
|
||||||
|
_settings.UseWindowsTerminal = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
UseWindowsTerminal.Unchecked += (o, e) =>
|
||||||
|
{
|
||||||
|
_settings.UseWindowsTerminal = false;
|
||||||
|
};
|
||||||
|
|
||||||
ReplaceWinR.Checked += (o, e) =>
|
ReplaceWinR.Checked += (o, e) =>
|
||||||
{
|
{
|
||||||
_settings.ReplaceWinR = true;
|
_settings.ReplaceWinR = true;
|
||||||
|
|
@ -91,8 +103,6 @@ namespace Flow.Launcher.Plugin.Shell
|
||||||
Shell.Cmd => 0,
|
Shell.Cmd => 0,
|
||||||
Shell.Powershell => 1,
|
Shell.Powershell => 1,
|
||||||
Shell.Pwsh => 2,
|
Shell.Pwsh => 2,
|
||||||
Shell.TerminalPWSH => 3,
|
|
||||||
Shell.TerminalCMD => 4,
|
|
||||||
_ => ShellComboBox.Items.Count - 1
|
_ => ShellComboBox.Items.Count - 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -103,8 +113,6 @@ namespace Flow.Launcher.Plugin.Shell
|
||||||
0 => Shell.Cmd,
|
0 => Shell.Cmd,
|
||||||
1 => Shell.Powershell,
|
1 => Shell.Powershell,
|
||||||
2 => Shell.Pwsh,
|
2 => Shell.Pwsh,
|
||||||
3 => Shell.TerminalPWSH,
|
|
||||||
4 => Shell.TerminalCMD,
|
|
||||||
_ => Shell.RunCommand
|
_ => Shell.RunCommand
|
||||||
};
|
};
|
||||||
LeaveShellOpen.IsEnabled = _settings.Shell != Shell.RunCommand;
|
LeaveShellOpen.IsEnabled = _settings.Shell != Shell.RunCommand;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue