Skip to content

Commit 4c5eae8

Browse files
committed
Implement CloseShellAfterPress (no logic)
Signed-off-by: Florian Grabmeier <[email protected]>
1 parent 026e5f5 commit 4c5eae8

File tree

6 files changed

+32
-2
lines changed

6 files changed

+32
-2
lines changed

Plugins/Flow.Launcher.Plugin.Shell/Languages/de.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
33

44
<system:String x:Key="flowlauncher_plugin_cmd_relace_winr">Ersetzt Win+R</system:String>
5+
<system:String x:Key="flowlauncher_plugin_cmd_close_cmd_after_press">Schließe die Kommandozeilte nachdem eine Taste gedrückt wurde</system:String>
56
<system:String x:Key="flowlauncher_plugin_cmd_leave_cmd_open">Schließe die Kommandozeilte nicht nachdem der Befehl ausgeführt wurde</system:String>
67
<system:String x:Key="flowlauncher_plugin_cmd_always_run_as_administrator">Immer als Administrator ausführen</system:String>
78
<system:String x:Key="flowlauncher_plugin_cmd_run_as_different_user">Als anderer Benutzer ausführen</system:String>

Plugins/Flow.Launcher.Plugin.Shell/Languages/en.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
xmlns:system="clr-namespace:System;assembly=mscorlib">
44

55
<system:String x:Key="flowlauncher_plugin_cmd_relace_winr">Replace Win+R</system:String>
6+
<system:String x:Key="flowlauncher_plugin_cmd_close_cmd_after_press">Close Command Prompt after pressing any key</system:String>
67
<system:String x:Key="flowlauncher_plugin_cmd_leave_cmd_open">Do not close Command Prompt after command execution</system:String>
78
<system:String x:Key="flowlauncher_plugin_cmd_always_run_as_administrator">Always run as administrator</system:String>
89
<system:String x:Key="flowlauncher_plugin_cmd_run_as_different_user">Run as different user</system:String>

Plugins/Flow.Launcher.Plugin.Shell/Main.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ private List<Result> ResultsFromHistory()
187187
return history.ToList();
188188
}
189189

190-
private ProcessStartInfo PrepareProcessStartInfo(string command, bool runAsAdministrator = false)
190+
private ProcessStartInfo PrepareProcessStartInfo(string command, bool runAsAdministrator = false) //TODO: implement logic for CloseCMDAfterPress
191191
{
192192
command = command.Trim();
193193
command = Environment.ExpandEnvironmentVariables(command);
@@ -203,7 +203,7 @@ private ProcessStartInfo PrepareProcessStartInfo(string command, bool runAsAdmin
203203
case Shell.Cmd:
204204
{
205205
info.FileName = "cmd.exe";
206-
info.Arguments = $"{(_settings.LeaveShellOpen ? "/k" : "/c")} {command}";
206+
info.Arguments = $"{(_settings.LeaveShellOpen ? "/k" : "/c")} {command} {(_settings.CloseShellAfterPress ? "& pause" : "")}";
207207

208208
//// Use info.Arguments instead of info.ArgumentList to enable users better control over the arguments they are writing.
209209
//// Previous code using ArgumentList, commands needed to be separated correctly:
@@ -233,6 +233,10 @@ private ProcessStartInfo PrepareProcessStartInfo(string command, bool runAsAdmin
233233
{
234234
info.ArgumentList.Add("-Command");
235235
info.ArgumentList.Add(command);
236+
if (_settings.CloseShellAfterPress)
237+
{
238+
info.ArgumentList.Add("; pause");
239+
}
236240
}
237241
break;
238242
}
@@ -246,6 +250,10 @@ private ProcessStartInfo PrepareProcessStartInfo(string command, bool runAsAdmin
246250
}
247251
info.ArgumentList.Add("-Command");
248252
info.ArgumentList.Add(command);
253+
if (_settings.CloseShellAfterPress)
254+
{
255+
info.ArgumentList.Add("; pause");
256+
}
249257

250258
break;
251259
}

Plugins/Flow.Launcher.Plugin.Shell/Settings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ public class Settings
77
public Shell Shell { get; set; } = Shell.Cmd;
88

99
public bool ReplaceWinR { get; set; } = false;
10+
11+
public bool CloseShellAfterPress { get; set; } = false;
1012

1113
public bool LeaveShellOpen { get; set; }
1214

Plugins/Flow.Launcher.Plugin.Shell/ShellSetting.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
Margin="10,10,5,5"
2323
HorizontalAlignment="Left"
2424
Content="{DynamicResource flowlauncher_plugin_cmd_relace_winr}" />
25+
<CheckBox
26+
x:Name="CloseShellAfterPress"
27+
Grid.Row="1"
28+
Margin="10,5,5,5"
29+
HorizontalAlignment="Left"
30+
Content="{DynamicResource flowlauncher_plugin_cmd_close_cmd_after_press}" />
2531
<CheckBox
2632
x:Name="LeaveShellOpen"
2733
Grid.Row="1"

Plugins/Flow.Launcher.Plugin.Shell/ShellSetting.xaml.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public CMDSetting(Settings settings)
1717
private void CMDSetting_OnLoaded(object sender, RoutedEventArgs re)
1818
{
1919
ReplaceWinR.IsChecked = _settings.ReplaceWinR;
20+
21+
CloseShellAfterPress.IsChecked = _settings.CloseShellAfterPress;
2022

2123
LeaveShellOpen.IsChecked = _settings.LeaveShellOpen;
2224

@@ -38,6 +40,16 @@ private void CMDSetting_OnLoaded(object sender, RoutedEventArgs re)
3840
_settings.ShowOnlyMostUsedCMDsNumber = (int)ShowOnlyMostUsedCMDsNumber.SelectedItem;
3941
}
4042

43+
CloseShellAfterPress.Checked += (o, e) =>
44+
{
45+
_settings.CloseShellAfterPress = true;
46+
};
47+
48+
CloseShellAfterPress.Unchecked += (o, e) =>
49+
{
50+
_settings.CloseShellAfterPress = false;
51+
};
52+
4153
LeaveShellOpen.Checked += (o, e) =>
4254
{
4355
_settings.LeaveShellOpen = true;

0 commit comments

Comments
 (0)