Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions Plugins/Flow.Launcher.Plugin.Shell/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
string basedir = null;
string dir = null;
string excmd = Environment.ExpandEnvironmentVariables(cmd);
if (Directory.Exists(excmd) && (cmd.EndsWith("/") || cmd.EndsWith(@"\")))

Check warning on line 48 in Plugins/Flow.Launcher.Plugin.Shell/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`excmd` is not a recognized word. (unrecognized-spelling)
{
basedir = excmd;

Check warning on line 50 in Plugins/Flow.Launcher.Plugin.Shell/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`excmd` is not a recognized word. (unrecognized-spelling)
dir = cmd;
}
else if (Directory.Exists(Path.GetDirectoryName(excmd) ?? string.Empty))

Check warning on line 53 in Plugins/Flow.Launcher.Plugin.Shell/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`excmd` is not a recognized word. (unrecognized-spelling)
{
basedir = Path.GetDirectoryName(excmd);

Check warning on line 55 in Plugins/Flow.Launcher.Plugin.Shell/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`excmd` is not a recognized word. (unrecognized-spelling)
var dirName = Path.GetDirectoryName(cmd);
dir = (dirName.EndsWith("/") || dirName.EndsWith(@"\")) ? dirName : cmd[..(dirName.Length + 1)];
}
Expand Down Expand Up @@ -129,7 +129,7 @@
}).Where(o => o != null);

if (_settings.ShowOnlyMostUsedCMDs)
return history.Take(_settings.ShowOnlyMostUsedCMDsNumber).ToList();

Check warning on line 132 in Plugins/Flow.Launcher.Plugin.Shell/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`CMDs` is not a recognized word. (unrecognized-spelling)

return history.ToList();
}
Expand Down Expand Up @@ -181,8 +181,8 @@
CopyText = m.Key
});

if (_settings.ShowOnlyMostUsedCMDs)

Check warning on line 184 in Plugins/Flow.Launcher.Plugin.Shell/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`CMDs` is not a recognized word. (unrecognized-spelling)
return history.Take(_settings.ShowOnlyMostUsedCMDsNumber).ToList();

Check warning on line 185 in Plugins/Flow.Launcher.Plugin.Shell/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`CMDs` is not a recognized word. (unrecognized-spelling)

return history.ToList();
}
Expand All @@ -194,10 +194,12 @@
var workingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
var runAsAdministratorArg = !runAsAdministrator && !_settings.RunAsAdministrator ? "" : "runas";

ProcessStartInfo info = new()
var info = new ProcessStartInfo()
{
Verb = runAsAdministratorArg, WorkingDirectory = workingDirectory,
Verb = runAsAdministratorArg,
WorkingDirectory = workingDirectory,
};
var notifyStr = Context.API.GetTranslation("flowlauncher_plugin_cmd_press_any_key_to_close");
switch (_settings.Shell)
{
case Shell.Cmd:
Expand All @@ -212,7 +214,11 @@
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" : "")}");
info.ArgumentList.Add(
$"{(_settings.LeaveShellOpen ? "/k" : "/c")} {command}" +
$"{(_settings.CloseShellAfterPress ?
$" && echo {notifyStr} && pause > nul /c" :
"")}");
break;
}

Expand All @@ -238,7 +244,11 @@
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" : "")}");
info.ArgumentList.Add(
$"{command}{addedCharacter};" +
$"{(_settings.CloseShellAfterPress ?
$" Write-Host '{notifyStr}'{addedCharacter}; [System.Console]::ReadKey(){addedCharacter}; exit" :
"")}");
}
break;
}
Expand All @@ -255,14 +265,18 @@
}
else
{
info.FileName = "pwsh.exe";

Check warning on line 268 in Plugins/Flow.Launcher.Plugin.Shell/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`pwsh` is not a recognized word. (unrecognized-spelling)
}
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" : "")}");
info.ArgumentList.Add(
$"{command}{addedCharacter};" +
$"{(_settings.CloseShellAfterPress ?
$" Write-Host '{notifyStr}'{addedCharacter}; [System.Console]::ReadKey(){addedCharacter}; exit" :
"")}");
break;
}

Expand Down Expand Up @@ -369,11 +383,11 @@
{
if (keyevent == (int)KeyEvent.WM_KEYDOWN && vkcode == (int)Keys.R && state.WinPressed)
{
_winRStroked = true;

Check warning on line 386 in Plugins/Flow.Launcher.Plugin.Shell/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`RStroked` is not a recognized word. (unrecognized-spelling)
OnWinRPressed();
return false;
}
if (keyevent == (int)KeyEvent.WM_KEYUP && _winRStroked && vkcode == (int)Keys.LWin)

Check warning on line 390 in Plugins/Flow.Launcher.Plugin.Shell/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`RStroked` is not a recognized word. (unrecognized-spelling)
{
_winRStroked = false;
_keyboardSimulator.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.CONTROL);
Expand Down
Loading