A new style desktop shell for Windows 11: menu bar, Dock, Finder, Spotlight, Control Center and Liquid Glass, in native C++.
Rust
Finder: open terminal from Go to Folder for cmd and PowerShell
Eternity070628bb63ce9579f1
diff --git a/src/finder/main.cpp b/src/finder/main.cppindex afd26c7..042df94 100644--- a/src/finder/main.cpp+++ b/src/finder/main.cpp@@ -4464,6 +4464,21 @@ static void GoRefresh() {FindClose(h);}+// Opens WacOS Terminal in folder 'dir' (cmd = Command Prompt, otherwise PowerShell). If WacOS Terminal is not installed,+// it falls back to the Windows cmd or PowerShell. A trailing backslash is doubled so the quoted --pasta argument keeps its+// closing quote (e.g. "C:\\").+static void OpenTerminalHere(std::wstring dir, bool cmd) {+ if (dir.empty()) { wchar_t prof[MAX_PATH] = {}; GetEnvironmentVariableW(L"USERPROFILE", prof, MAX_PATH); dir = prof; }+ wchar_t exe[MAX_PATH]; ExePath(exe, MAX_PATH); PathRemoveFileSpecW(exe);+ std::wstring term = std::wstring(exe) + L"\\WacOSTerminal.exe";+ std::wstring arg = dir;+ if (arg.size() > 1 && arg.back() == L'\\') arg += L'\\';+ if (GetFileAttributesW(term.c_str()) != INVALID_FILE_ATTRIBUTES)+ ShellExecuteW(nullptr, L"open", term.c_str(), ((cmd ? L"--cmd " : L"") + std::wstring(L"--pasta \"") + arg + L"\"").c_str(), nullptr, SW_SHOWNORMAL);+ else if (cmd) ShellExecuteW(nullptr, L"open", L"cmd.exe", nullptr, dir.c_str(), SW_SHOWNORMAL);+ else ShellExecuteW(nullptr, L"open", L"powershell.exe", L"-NoExit", dir.c_str(), SW_SHOWNORMAL);+}+static void GoOpen(bool on) {g_goOpen = on;if (on) { g_go.SetText(L"", false); GoRefresh(); g_caretOn = true; }@@ -4471,6 +4486,15 @@ static void GoOpen(bool on) {}static void GoAccept() {+ { // Typing cmd, powershell, pwsh or wt (as in Windows Explorer) opens the terminal in the current folder+ std::wstring t = g_go.text;+ while (!t.empty() && iswspace(t.back())) t.pop_back();+ while (!t.empty() && iswspace(t.front())) t.erase(0, 1);+ for (auto& c : t) c = towlower(c);+ bool cmd = t == L"cmd" || t == L"cmd.exe";+ bool ps = t == L"powershell" || t == L"powershell.exe" || t == L"pwsh" || t == L"pwsh.exe" || t == L"wt" || t == L"wt.exe";+ if (cmd || ps) { GoOpen(false); OpenTerminalHere(g_folder, cmd); return; }+ }std::wstring target = g_goSel >= 0 && g_goSel < (int)g_goSugg.size() ? g_goSugg[g_goSel] : GoExpand(g_go.text);while (target.size() > 3 && target.back() == L'\\') target.pop_back();DWORD a = GetFileAttributesW(target.c_str());