From 9ce6911b49264d14e406d37d8c58a6d235bd5d95 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Fri, 24 Nov 2023 15:14:09 -0500 Subject: [PATCH 01/18] add bash and powershell to Cmder for Windows --- launcher/src/CmderLauncher.cpp | 111 +++++++++++++++++++-------------- 1 file changed, 65 insertions(+), 46 deletions(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index 0ff43d68f..d423c4483 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -131,8 +131,10 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr wchar_t windowsTerminalDir[MAX_PATH] = { 0 }; wchar_t conEmuDir[MAX_PATH] = { 0 }; wchar_t winDir[MAX_PATH] = { 0 }; - wchar_t emulatorPath[MAX_PATH] = { 0 }; - + wchar_t vendorDir[MAX_PATH] = { 0 }; + wchar_t initCmd[MAX_PATH] = { 0 }; + wchar_t initPowerShell[MAX_PATH] = { 0 }; + wchar_t initBash[MAX_PATH] = { 0 }; std::wstring cmderStart = path; std::wstring cmderTask = taskName; @@ -255,8 +257,9 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr } } - PathCombine(windowsTerminalDir, exeDir, L"vendor\\windows-terminal"); - PathCombine(conEmuDir, exeDir, L"vendor\\conemu-maximus5"); + PathCombine(vendorDir, exeDir, L"vendor"); + PathCombine(windowsTerminalDir, vendorDir, L"windows-terminal"); + PathCombine(conEmuDir, vendorDir, L"conemu-maximus5"); GetEnvironmentVariable(L"WINDIR", winDir, MAX_PATH); if (PathFileExists(windowsTerminalDir)) @@ -317,7 +320,8 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr { if (!CopyFile(cpuCfgPath, cfgPath, FALSE)) { - if (PathFileExists(windowsTerminalDir)) { + if (PathFileExists(windowsTerminalDir)) + { MessageBox(NULL, (GetLastError() == ERROR_ACCESS_DENIED) ? L"Failed to copy config/windows_terminal_%COMPUTERNAME%_settings.json file to vendor/windows-terminal/settings/settings.json! Access Denied." @@ -343,7 +347,8 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr { if (!CopyFile(cfgPath, userCfgPath, FALSE)) { - if (PathFileExists(windowsTerminalDir)) { + if (PathFileExists(windowsTerminalDir)) + { MessageBox(NULL, (GetLastError() == ERROR_ACCESS_DENIED) ? L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/windows_terminal_settings.json! Access Denied." @@ -364,7 +369,8 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr { if (!CopyFile(userCfgPath, cfgPath, FALSE)) { - if (PathFileExists(windowsTerminalDir)) { + if (PathFileExists(windowsTerminalDir)) + { MessageBox(NULL, (GetLastError() == ERROR_ACCESS_DENIED) ? L"Failed to copy config/user_windows_terminal_settings.json file to vendor/windows-terminal/settings/settings.json! Access Denied." @@ -392,7 +398,8 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr { if (!CopyFile(cfgPath, userCfgPath, FALSE)) { - if (PathFileExists(windowsTerminalDir)) { + if (PathFileExists(windowsTerminalDir)) + { MessageBox(NULL, (GetLastError() == ERROR_ACCESS_DENIED) ? L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/user_windows_terminal_settings.json! Access Denied." @@ -412,7 +419,8 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr { if (!CopyFile(defaultCfgPath, cfgPath, FALSE)) { - if (PathFileExists(windowsTerminalDir)) { + if (PathFileExists(windowsTerminalDir)) + { MessageBox(NULL, (GetLastError() == ERROR_ACCESS_DENIED) ? L"Failed to copy vendor/windows-terminal_default_settings_settings.json file to vendor/windows-terminal/settings/settings.json! Access Denied." @@ -428,7 +436,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr exit(1); } } - } + } } else if (!CopyFile(defaultCfgPath, cfgPath, FALSE) && PathFileExists(conEmuDir)) { @@ -436,14 +444,15 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr (GetLastError() == ERROR_ACCESS_DENIED) ? L"Failed to copy vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml! Access Denied." : L"Failed to copy vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml!", MB_TITLE, MB_ICONSTOP); - exit(1); + exit(1); } } else if (wcscmp(cfgPath, L"") == 0 && PathFileExists(cfgPath)) // vendor/conemu-maximus5/ConEmu.xml exists, copy vendor/conemu-maximus5/ConEmu.xml to config/user_conemu.xml { if (!CopyFile(cfgPath, userCfgPath, FALSE)) { - if (PathFileExists(windowsTerminalDir)) { + if (PathFileExists(windowsTerminalDir)) + { MessageBox(NULL, (GetLastError() == ERROR_ACCESS_DENIED) ? L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/user_windows_terminal_settings_settings.json! Access Denied." @@ -464,9 +473,10 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr } else if (wcscmp(defaultCfgPath, L"") == 0) // '/c [path]' was specified and 'vendor/ConEmu.xml.default' config exists, copy Cmder 'vendor/ConEmu.xml.default' file to '[user specified path]/config/user_ConEmu.xml'. { - if ( ! CopyFile(defaultCfgPath, userCfgPath, FALSE)) + if (!CopyFile(defaultCfgPath, userCfgPath, FALSE)) { - if (PathFileExists(windowsTerminalDir)) { + if (PathFileExists(windowsTerminalDir)) + { MessageBox(NULL, (GetLastError() == ERROR_ACCESS_DENIED) ? L"Failed to copy vendor/windows-terminal_default_settings_settings.json file to [user specified path]/config/user_windows_terminal_settings.json! Access Denied." @@ -487,21 +497,27 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr SYSTEM_INFO sysInfo; GetNativeSystemInfo(&sysInfo); - if (PathFileExists(windowsTerminalDir)) { + if (PathFileExists(windowsTerminalDir)) + { PathCombine(terminalPath, exeDir, L"vendor\\windows-terminal\\WindowsTerminal.exe"); } else if (PathFileExists(conEmuDir)) { + swprintf_s(args, L"%s /Icon \"%s\"", args, icoPath); + swprintf_s(args, L"%s /title \"%s\"", args, cmderTitle.c_str()); PathCombine(terminalPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu64.exe"); } else { - PathCombine(terminalPath, winDir, L"system32\\cmd.exe"); - } - - if (!PathFileExists(windowsTerminalDir)) { - swprintf_s(args, L"%s /Icon \"%s\"", args, icoPath); - } + if (streqi(cmderTask.c_str(), L"powershell")) + { + PathCombine(terminalPath, winDir, L"System32\\WindowsPowerShell\\v1.0\\powershell.exe"); + } + else + { + PathCombine(terminalPath, winDir, L"system32\\cmd.exe"); + } + } if (!streqi(cmderStart.c_str(), L"")) { @@ -521,13 +537,6 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr } } - if (!streqi(cmderTitle.c_str(), L"")) - { - if (!PathFileExists(windowsTerminalDir)) { - swprintf_s(args, L"%s /title \"%s\"", args, cmderTitle.c_str()); - } - } - if (cfgRoot.length() != 0) { if (!PathFileExists(windowsTerminalDir)) { @@ -543,6 +552,10 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr // The `/run` arg and its value MUST be the last arg of ConEmu // see : https://conemu.github.io/en/ConEmuArgs.html // > This must be the last used switch (excepting -new_console and -cur_console) + PathCombine(initCmd, vendorDir, L"init.bat"); + PathCombine(initPowerShell, vendorDir, L"profile.ps1"); + PathCombine(initBash, vendorDir, L"start_git_bash.cmd"); + if (!streqi(cmderTask.c_str(), L"")) { if (PathFileExists(windowsTerminalDir)) { @@ -554,7 +567,18 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr } else { - swprintf_s(args, L"%s %s", args, cmderTask.c_str()); + if (streqi(cmderTask.c_str(), L"powershell")) + { + swprintf_s(args, L"%s -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command \"Invoke-Expression 'Import-Module ''%s'''\"", args, initPowerShell); + } + else if (streqi(cmderTask.c_str(), L"bash")) + { + swprintf_s(args, L"%s /k \"%s\"", args, initBash); + } + else + { + swprintf_s(args, L"%s /k \"%s\"", args, initCmd); + } } } @@ -581,7 +605,8 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr if (!CreateProcess(terminalPath, args, NULL, NULL, false, 0, NULL, NULL, &si, &pi)) { - if (PathFileExists(windowsTerminalDir)) { + if (PathFileExists(windowsTerminalDir)) + { MessageBox(NULL, _T("Unable to create the Windows Terminal process!"), _T("Error"), MB_OK); } else if (PathFileExists(conEmuDir)) @@ -726,7 +751,6 @@ cmderOptions GetOption() wchar_t conEmuDir[MAX_PATH] = { 0 }; wchar_t vendorDir[MAX_PATH] = { 0 }; wchar_t exeDir[MAX_PATH] = { 0 }; - wchar_t cmdInit[MAX_PATH] = { 0 }; GetModuleFileName(NULL, exeDir, sizeof(exeDir)); PathRemoveFileSpec(exeDir); @@ -734,7 +758,6 @@ cmderOptions GetOption() PathCombine(vendorDir, exeDir, L"vendor"); PathCombine(windowsTerminalDir, vendorDir, L"windows-terminal"); PathCombine(conEmuDir, vendorDir, L"ConEmu-Maximus5"); - PathCombine(cmdInit, vendorDir, L"init.bat"); szArgList = CommandLineToArgvW(GetCommandLine(), &argCount); @@ -849,7 +872,7 @@ cmderOptions GetOption() { szArgList[i][len - 1] = '\0'; } - + if (PathFileExists(szArgList[i])) { cmderOptions.cmderStart = szArgList[i]; @@ -865,14 +888,11 @@ cmderOptions GetOption() cmderOptions.error = true; } } - } - if (!PathFileExists(windowsTerminalDir) && !PathFileExists(conEmuDir)) + if (!PathFileExists(windowsTerminalDir) && !PathFileExists(conEmuDir) && streqi(cmderOptions.cmderTask.c_str(), L"")) { - cmderOptions.cmderTask = L"/k \""; - cmderOptions.cmderTask += cmdInit; - cmderOptions.cmderTask += L"\""; + cmderOptions.cmderTask = L"cmder"; } if (cmderOptions.error == true) @@ -906,17 +926,16 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, GetModuleFileName(NULL, exeDir, sizeof(exeDir)); PathRemoveFileSpec(exeDir); - - PathCombine(windowsTerminalDir, exeDir, L"vendor\\windows-terminal"); + PathCombine(windowsTerminalDir, exeDir, L"vendor\\windows-terminal"); if (cmderOptions.registerApp == true) { - if (PathFileExists(windowsTerminalDir)) - { - RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_BACKGROUND, cmderOptions.cmderCfgRoot, cmderOptions.cmderSingle); - RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_LISTITEM, cmderOptions.cmderCfgRoot, cmderOptions.cmderSingle); - RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_DRIVE_PATH_BACKGROUND, cmderOptions.cmderCfgRoot, cmderOptions.cmderSingle); - RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_DRIVE_PATH_LISTITEM, cmderOptions.cmderCfgRoot, cmderOptions.cmderSingle); + if (PathFileExists(windowsTerminalDir)) + { + RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_BACKGROUND, cmderOptions.cmderCfgRoot, cmderOptions.cmderSingle); + RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_LISTITEM, cmderOptions.cmderCfgRoot, cmderOptions.cmderSingle); + RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_DRIVE_PATH_BACKGROUND, cmderOptions.cmderCfgRoot, cmderOptions.cmderSingle); + RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_DRIVE_PATH_LISTITEM, cmderOptions.cmderCfgRoot, cmderOptions.cmderSingle); } else { From 467d564a7b75e35d6bc9604747cb4643dd479e7e Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Fri, 24 Nov 2023 15:19:49 -0500 Subject: [PATCH 02/18] cleanup --- launcher/src/CmderLauncher.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index d423c4483..a57a7651c 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -1,4 +1,4 @@ -#include / +#include #include #include #include "resource.h" From a7f19f56e8396b0e7a41fb75f2d1b23aa8b4473e Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Fri, 24 Nov 2023 15:25:46 -0500 Subject: [PATCH 03/18] cleanup --- launcher/src/CmderLauncher.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index a57a7651c..51f5e1aa1 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -516,8 +516,8 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr else { PathCombine(terminalPath, winDir, L"system32\\cmd.exe"); - } - } + } + } if (!streqi(cmderStart.c_str(), L"")) { From 2beb27d490b7398f86e5c6e641a0b357a859f6f6 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Fri, 24 Nov 2023 15:27:19 -0500 Subject: [PATCH 04/18] cleanup --- launcher/src/CmderLauncher.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index 51f5e1aa1..edc4e50f6 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -599,7 +599,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr si.dwFlags = STARTF_TITLEISAPPID; #endif PROCESS_INFORMATION pi; - + // MessageBox(NULL, terminalPath, _T("Error"), MB_OK); // MessageBox(NULL, args, _T("Error"), MB_OK); @@ -872,7 +872,7 @@ cmderOptions GetOption() { szArgList[i][len - 1] = '\0'; } - + if (PathFileExists(szArgList[i])) { cmderOptions.cmderStart = szArgList[i]; From 0f6c91d03a3dd99b18cd3b88049b548ba447e15b Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Fri, 24 Nov 2023 16:22:49 -0500 Subject: [PATCH 05/18] cleanup --- launcher/src/CmderLauncher.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index edc4e50f6..dec8da79c 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -573,7 +573,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr } else if (streqi(cmderTask.c_str(), L"bash")) { - swprintf_s(args, L"%s /k \"%s\"", args, initBash); + swprintf_s(args, L"%s /c \"%s\"", args, initBash); } else { From 7a385ebf751e88348e8664750a7bc27fdab50e9e Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Fri, 24 Nov 2023 16:28:44 -0500 Subject: [PATCH 06/18] cleanup --- launcher/src/CmderLauncher.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index dec8da79c..f117d2be2 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -932,10 +932,10 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, { if (PathFileExists(windowsTerminalDir)) { - RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_BACKGROUND, cmderOptions.cmderCfgRoot, cmderOptions.cmderSingle); - RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_LISTITEM, cmderOptions.cmderCfgRoot, cmderOptions.cmderSingle); - RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_DRIVE_PATH_BACKGROUND, cmderOptions.cmderCfgRoot, cmderOptions.cmderSingle); - RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_DRIVE_PATH_LISTITEM, cmderOptions.cmderCfgRoot, cmderOptions.cmderSingle); + RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_BACKGROUND, cmderOptions.cmderCfgRoot, cmderOptions.cmderSingle); + RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_LISTITEM, cmderOptions.cmderCfgRoot, cmderOptions.cmderSingle); + RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_DRIVE_PATH_BACKGROUND, cmderOptions.cmderCfgRoot, cmderOptions.cmderSingle); + RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_DRIVE_PATH_LISTITEM, cmderOptions.cmderCfgRoot, cmderOptions.cmderSingle); } else { From d8238b0230d1ff3200955b6741864c8c5c9c0576 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Fri, 24 Nov 2023 18:18:16 -0500 Subject: [PATCH 07/18] cleanup --- launcher/src/CmderLauncher.cpp | 40 ++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index f117d2be2..a57e65a62 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -105,7 +105,7 @@ bool FileExists(const wchar_t * filePath) return false; } -void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstring taskName = L"", std::wstring title = L"", std::wstring iconPath = L"", std::wstring cfgRoot = L"", bool use_user_cfg = true, std::wstring conemu_args = L"") +void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstring taskName = L"", std::wstring title = L"", std::wstring iconPath = L"", std::wstring cfgRoot = L"", bool use_user_cfg = true, std::wstring conemu_args = L"", bool admin = false) { #if USE_TASKBAR_API wchar_t appId[MAX_PATH] = { 0 }; @@ -602,8 +602,36 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr // MessageBox(NULL, terminalPath, _T("Error"), MB_OK); // MessageBox(NULL, args, _T("Error"), MB_OK); + // Let's try to rerun as Administrator + SHELLEXECUTEINFO sei = { sizeof(sei) }; + sei.fMask = SEE_MASK_NOASYNC | SEE_MASK_NOCLOSEPROCESS; + sei.lpVerb = L"runas"; + sei.lpFile = terminalPath; + sei.lpParameters = args; + sei.nShow = SW_SHOWNORMAL; + + if (admin && ShellExecuteEx(&sei)) + { + if (!sei.hProcess) + { + Sleep(500); + _ASSERTE(sei.hProcess != nullptr); + } + + if (sei.hProcess) + { + WaitForSingleObject(sei.hProcess, INFINITE); + } - if (!CreateProcess(terminalPath, args, NULL, NULL, false, 0, NULL, NULL, &si, &pi)) + // int nZone = 0; + // if (!HasZoneIdentifier(lsFile, nZone) + // || (nZone != 0 /*LocalComputer*/)) + // { + // // Assuming that elevated copy has fixed all zone problems + // break; + // } + } + else if (!CreateProcess(terminalPath, args, NULL, NULL, false, 0, NULL, NULL, &si, &pi)) { if (PathFileExists(windowsTerminalDir)) { @@ -734,6 +762,7 @@ struct cmderOptions std::wstring cmderIcon = L""; std::wstring cmderRegScope = L"USER"; std::wstring cmderTerminalArgs = L""; + bool cmderAdmin = false; bool cmderSingle = false; bool cmderUserCfg = true; bool registerApp = false; @@ -822,6 +851,10 @@ cmderOptions GetOption() { cmderOptions.cmderUserCfg = false; } + else if (_wcsicmp(L"/a", szArgList[i]) == 0 && !PathFileExists(windowsTerminalDir) && !PathFileExists(conEmuDir)) + { + cmderOptions.cmderAdmin = true; + } else if (_wcsicmp(L"/register", szArgList[i]) == 0) { cmderOptions.registerApp = true; @@ -958,8 +991,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, } else { - StartCmder(cmderOptions.cmderStart, cmderOptions.cmderSingle, cmderOptions.cmderTask, cmderOptions.cmderTitle, cmderOptions.cmderIcon, cmderOptions.cmderCfgRoot, cmderOptions.cmderUserCfg, cmderOptions.cmderTerminalArgs); - } + StartCmder(cmderOptions.cmderStart, cmderOptions.cmderSingle, cmderOptions.cmderTask, cmderOptions.cmderTitle, cmderOptions.cmderIcon, cmderOptions.cmderCfgRoot, cmderOptions.cmderUserCfg, cmderOptions.cmderTerminalArgs, cmderOptions.cmderAdmin); } return 0; } From 47292038efcfa55507425f8741a6810e1690d453 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 26 Nov 2023 21:35:30 -0500 Subject: [PATCH 08/18] add mintty --- launcher/src/CmderLauncher.cpp | 55 +++++++++++++++++++++++++++++++--- launcher/src/strings.rc2 | 2 +- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index a57e65a62..1181db057 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -135,6 +135,12 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr wchar_t initCmd[MAX_PATH] = { 0 }; wchar_t initPowerShell[MAX_PATH] = { 0 }; wchar_t initBash[MAX_PATH] = { 0 }; + wchar_t vendoredGit[MAX_PATH] = { 0 }; + wchar_t amdx64Git[MAX_PATH] = { 0 }; + wchar_t x86Git[MAX_PATH] = { 0 }; + wchar_t programFiles[MAX_PATH] = { 0 }; + wchar_t programFilesX86[MAX_PATH] = { 0 }; + wchar_t minTTYPath[MAX_PATH] = { 0 }; std::wstring cmderStart = path; std::wstring cmderTask = taskName; @@ -495,6 +501,13 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr PathCombine(userConEmuCfgPath, userConfigDirPath, L"user-ConEmu.xml"); } + GetEnvironmentVariable(L"ProgramFiles", programFiles, MAX_PATH); + GetEnvironmentVariable(L"ProgramFiles(x86)", programFilesX86, MAX_PATH); + + PathCombine(vendoredGit, vendorDir, L"git-for-windows"); + PathCombine(amdx64Git, programFiles, L"Git"); + PathCombine(x86Git, programFilesX86, L"Git"); + SYSTEM_INFO sysInfo; GetNativeSystemInfo(&sysInfo); if (PathFileExists(windowsTerminalDir)) @@ -509,13 +522,26 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr } else { + PathCombine(terminalPath, winDir, L"system32\\cmd.exe"); + if (streqi(cmderTask.c_str(), L"powershell")) { PathCombine(terminalPath, winDir, L"System32\\WindowsPowerShell\\v1.0\\powershell.exe"); } - else + else if (streqi(cmderTask.c_str(), L"mintty")) { - PathCombine(terminalPath, winDir, L"system32\\cmd.exe"); + if (PathFileExists(vendoredGit)) + { + PathCombine(terminalPath, vendoredGit, L"git-bash.exe"); + } + else if (PathFileExists(amdx64Git)) + { + PathCombine(terminalPath, amdx64Git, L"git-bash.exe"); + } + else if (PathFileExists(x86Git)) + { + PathCombine(terminalPath, x86Git, L"git-bash.exe"); + } } } @@ -575,7 +601,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr { swprintf_s(args, L"%s /c \"%s\"", args, initBash); } - else + else if (streqi(cmderTask.c_str(), L"cmder")) { swprintf_s(args, L"%s /k \"%s\"", args, initCmd); } @@ -589,6 +615,27 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr SetEnvironmentVariable(L"CMDER_USER_BIN", userBinDirPath); } + // Try to find m'intty.exe' so ConEmu can launch using %MINTTY_EXE% in external Git for Cmder Mini. + // See: https://github.com/Maximus5/ConEmu/issues/2559 for why this is commented. + + /* + if (PathFileExists(vendoredGit)) + { + PathCombine(minTTYPath, vendoredGit, L"usr\\bin\\mintty.exe"); + SetEnvironmentVariable(L"MINTTY_EXE", minTTYPath); + } + else if (PathFileExists(amdx64Git)) + { + PathCombine(minTTYPath, amdx64Git, L"usr\\bin\\mintty.exe"); + SetEnvironmentVariable(L"MINTTY_EXE", minTTYPath); + } + else if (PathFileExists(x86Git)) + { + PathCombine(minTTYPath, x86Git, L"usr\\bin\\mintty.exe"); + SetEnvironmentVariable(L"MINTTY_EXE", minTTYPath); + } + */ + // Ensure EnvironmentVariables are propagated. STARTUPINFO si = { 0 }; @@ -994,4 +1041,4 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, StartCmder(cmderOptions.cmderStart, cmderOptions.cmderSingle, cmderOptions.cmderTask, cmderOptions.cmderTitle, cmderOptions.cmderIcon, cmderOptions.cmderCfgRoot, cmderOptions.cmderUserCfg, cmderOptions.cmderTerminalArgs, cmderOptions.cmderAdmin); } return 0; -} +} \ No newline at end of file diff --git a/launcher/src/strings.rc2 b/launcher/src/strings.rc2 index d8feb4d8b..494cbfeec 100644 --- a/launcher/src/strings.rc2 +++ b/launcher/src/strings.rc2 @@ -6,7 +6,7 @@ STRINGTABLE { IDS_TITLE "Cmder Launcher" - IDS_SWITCHES L"Valid options:\n\n /c [CMDER User Root Path]\n /task [Windows Terminal Profile/ConEmu Task Name]\n /icon [CMDER Icon Path] - ConEmu ONLY!\n [/start [Start in Path] | [Start in Path]]\n /single - ConEmu ONLY!\n /m\n -- [ConEmu/Windows Terminal extra arguments]\n\nNote: '-- [...]' must be the last argument!\n\nor, either:\n /register [USER | ALL]\n /unregister [USER | ALL]" + IDS_SWITCHES L"Valid options:\n\n /a Admin - Native Terminals ONLY!\n /c [CMDER User Root Path]\n /task [Windows Terminal Profile/ConEmu Task Name]\n /icon [CMDER Icon Path] - ConEmu ONLY!\n [/start [Start in Path] | [Start in Path]]\n /single - ConEmu ONLY!\n /m\n -- [ConEmu/Windows Terminal extra arguments]\n\nNote: '-- [...]' must be the last argument!\n\nor, either:\n /register [USER | ALL]\n /unregister [USER | ALL]" } ///////////////////////////////////////////////////////////////////////////// From 38a91ded0294975829d06c408bc4bfeaa59eaab1 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 26 Nov 2023 22:28:16 -0500 Subject: [PATCH 09/18] cleanup --- launcher/src/CmderLauncher.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index 1181db057..e8a13e489 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -442,7 +442,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr exit(1); } } - } + } } else if (!CopyFile(defaultCfgPath, cfgPath, FALSE) && PathFileExists(conEmuDir)) { From 28e9018ce0673398e9ca4d2102843e4a5c06cb27 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Mon, 27 Nov 2023 10:00:28 -0500 Subject: [PATCH 10/18] make mintty /a work --- launcher/src/CmderLauncher.cpp | 8 +++++++ vendor/start_git_mintty.cmd | 40 ++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 vendor/start_git_mintty.cmd diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index e8a13e489..782095d7e 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -135,6 +135,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr wchar_t initCmd[MAX_PATH] = { 0 }; wchar_t initPowerShell[MAX_PATH] = { 0 }; wchar_t initBash[MAX_PATH] = { 0 }; + wchar_t initMintty[MAX_PATH] = { 0 }; wchar_t vendoredGit[MAX_PATH] = { 0 }; wchar_t amdx64Git[MAX_PATH] = { 0 }; wchar_t x86Git[MAX_PATH] = { 0 }; @@ -528,6 +529,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr { PathCombine(terminalPath, winDir, L"System32\\WindowsPowerShell\\v1.0\\powershell.exe"); } + /* else if (streqi(cmderTask.c_str(), L"mintty")) { if (PathFileExists(vendoredGit)) @@ -543,6 +545,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr PathCombine(terminalPath, x86Git, L"git-bash.exe"); } } + */ } if (!streqi(cmderStart.c_str(), L"")) @@ -581,6 +584,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr PathCombine(initCmd, vendorDir, L"init.bat"); PathCombine(initPowerShell, vendorDir, L"profile.ps1"); PathCombine(initBash, vendorDir, L"start_git_bash.cmd"); + PathCombine(initMintty, vendorDir, L"start_git_mintty.cmd"); if (!streqi(cmderTask.c_str(), L"")) { @@ -601,6 +605,10 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr { swprintf_s(args, L"%s /c \"%s\"", args, initBash); } + else if (streqi(cmderTask.c_str(), L"mintty")) + { + swprintf_s(args, L"%s /c \"%s\"", args, initMintty); + } else if (streqi(cmderTask.c_str(), L"cmder")) { swprintf_s(args, L"%s /k \"%s\"", args, initCmd); diff --git a/vendor/start_git_mintty.cmd b/vendor/start_git_mintty.cmd new file mode 100644 index 000000000..ea4f09a9f --- /dev/null +++ b/vendor/start_git_mintty.cmd @@ -0,0 +1,40 @@ +@echo off + +if not defined CMDER_ROOT ( + if defined ConEmuDir ( + for /f "delims=" %%i in ("%ConEmuDir%\..\..") do ( + set "CMDER_ROOT=%%~fi" + ) + ) else ( + for /f "delims=" %%i in ("%~dp0\..") do ( + set "CMDER_ROOT=%%~fi" + ) + ) +) + +if exist "%CMDER_ROOT%\vendor\git-for-windows" ( + set "PATH=%CMDER_ROOT%\vendor\git-for-windows\usr\bin;%PATH%" + set "gitCmd=%CMDER_ROOT%\vendor\git-for-windows\usr\bin\mintty.exe" +) else if exist "%ProgramFiles%\git" ( + set "PATH=%ProgramFiles%\git\usr\bin;%PATH%" + set "gitCmd=%ProgramFiles%\git\usr\bin\mintty.exe" + if not exist "%ProgramFiles%\git\etc\profile.d\cmder_exinit.sh" ( + echo Run 'mklink "%ProgramFiles%\git\etc\profile.d\cmder_exinit.sh" "%CMDER_ROOT%\vendor\cmder_exinit"' in 'cmd::Cmder as Admin' to use Cmder with external Git Bash + echo. + echo or + echo. + echo Run 'echo "" ^> "%ProgramFiles%\git\etc\profile.d\cmder_exinit.sh"' in 'cmd::Cmder as Admin' to disable this message. + ) +) else if exist "%ProgramFiles(x86)%\git" ( + set "PATH=%ProgramFiles(x86)%\git\usr\bin;%PATH%" + set "gitCmd=%ProgramFiles(x86)%\git\usr\bin\mintty.exe" + if not exist "%ProgramFiles(x86)%\git\etc\profile.d\cmder_exinit.sh" ( + echo Run 'mklink "%ProgramFiles^(x86^)%\git\etc\profile.d\cmder_exinit.sh" "%CMDER_ROOT%\vendor\cmder_exinit"' in 'cmd::Cmder as Admin' to use Cmder with external Git Bash + echo. + echo or + echo. + echo Run 'echo "" ^> "%ProgramFiles^(x86^)%\git\etc\profile.d\cmder_exinit.sh"' in 'cmd::Cmder as Admin' to disable this message. + ) +) + +"%gitCmd%" /bin/bash -l From c5579d2cab83828ac3756429c6290918e12bf03d Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Tue, 2 Jan 2024 11:20:20 -0500 Subject: [PATCH 11/18] Add Monokai, Default to One Half Dark --- vendor/windows_terminal_default_settings.json | 78 ++++++++++++++++--- 1 file changed, 67 insertions(+), 11 deletions(-) diff --git a/vendor/windows_terminal_default_settings.json b/vendor/windows_terminal_default_settings.json index 59ee82a48..f630811ed 100644 --- a/vendor/windows_terminal_default_settings.json +++ b/vendor/windows_terminal_default_settings.json @@ -47,70 +47,80 @@ ], "profiles": { - "defaults": {}, + "defaults": + { + "colorScheme": "One Half Dark", + "font": + { + "face": "Cascadia Code" + } + }, "list": [ { - "colorScheme": "Campbell", + "colorScheme": "One Half Dark", "commandline": "cmd /k \"%CMDER_ROOT%\\vendor\\init.bat\"", "guid": "{48946353-ebe8-4571-a591-7d609f31327a}", "hidden": false, "icon": "%CMDER_ROOT%\\icons\\cmder.ico", "name": "Cmder", - "startingDirectory": "", + "startingDirectory": null, "tabTitle": "Cmder", "useAtlasEngine": false }, { + "colorScheme": "One Half Dark", "commandline": "%SystemRoot%\\System32\\cmd.exe /k \"%CMDER_ROOT%\\vendor\\init.bat\"", "elevate": true, "guid": "{bdd957d0-c15a-49e6-9816-14b02351a071}", "hidden": false, "icon": "%CMDER_ROOT%\\icons\\cmder_red.ico", "name": "Cmder as Admin", - "startingDirectory": "", + "startingDirectory": null, "tabTitle": "Cmder as Admin" }, { - "colorScheme": "Campbell", + "colorScheme": "One Half Dark", "commandline": "PowerShell -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command \"Invoke-Expression 'Import-Module ''%CMDER_ROOT%\\vendor.\\profile.ps1'''\"", "guid": "{eb1f6578-ce9d-47a9-a8c7-9b3fdd22302d}", "hidden": false, "icon": "%CMDER_ROOT%\\icons\\cmder_orange.ico", "name": "Cmder - PowerShell", - "startingDirectory": "", + "startingDirectory": null, "tabTitle": "Cmder", "useAtlasEngine": false }, { - "colorScheme": "Campbell", + "colorScheme": "One Half Dark", "commandline": "PowerShell -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command \"Invoke-Expression 'Import-Module ''%CMDER_ROOT%\\vendor.\\profile.ps1'''\"", "elevate": true, "guid": "{c5225c3e-8619-4145-8182-2800814eeb17}", "hidden": false, "icon": "%CMDER_ROOT%\\icons\\cmder_purple.ico", "name": "Cmder - PowerShell as Admin", - "startingDirectory": "", + "startingDirectory": null, "tabTitle": "Cmder - PowerShell as Admin", "useAtlasEngine": false }, { + "colorScheme": "One Half Dark", "commandline": "%CMDER_ROOT%\\vendor\\start_git_bash.cmd", "guid": "{c5c298e9-010e-4b8c-bc55-e3df81846b4c}", "hidden": false, "icon": "%CMDER_ROOT%\\icons\\cmder_blue.ico", "name": "Cmder - Bash", - "startingDirectory": "", + "startingDirectory": null, "tabTitle": "Cmder - Bash" }, { + "colorScheme": "One Half Dark", "commandline": "%CMDER_ROOT%\\vendor\\start_git_bash.cmd", "elevate": true, "guid": "{545eb9ed-4c1c-49b3-8cc6-7eb41bd280ff}", "hidden": false, "icon": "%CMDER_ROOT%\\icons\\cmder_yellow.ico", "name": "Cmder - Bash as Admin", - "startingDirectory": "", + "startingDirectory": null, "tabTitle": "Cmder - Bash as Admin" }, { @@ -176,6 +186,52 @@ "white": "#CCCCCC", "yellow": "#C19C00" }, + { + "background": "#282828", + "black": "#282828", + "blue": "#458588", + "brightBlack": "#928374", + "brightBlue": "#83A598", + "brightCyan": "#8EC07C", + "brightGreen": "#B8BB26", + "brightPurple": "#D3869B", + "brightRed": "#FB4934", + "brightWhite": "#EBDBB2", + "brightYellow": "#FABD2F", + "cursorColor": "#FFFFFF", + "cyan": "#689D6A", + "foreground": "#EBDBB2", + "green": "#98971A", + "name": "Gruvbox Dark", + "purple": "#B16286", + "red": "#CC241D", + "selectionBackground": "#FFFFFF", + "white": "#A89984", + "yellow": "#D79921" + }, + { + "background": "#272822", + "black": "#3E3D32", + "blue": "#03395C", + "brightBlack": "#272822", + "brightBlue": "#66D9EF", + "brightCyan": "#66D9EF", + "brightGreen": "#A6E22E", + "brightPurple": "#AE81FF", + "brightRed": "#F92672", + "brightWhite": "#F8F8F2", + "brightYellow": "#FD971F", + "cursorColor": "#FFFFFF", + "cyan": "#66D9EF", + "foreground": "#F8F8F2", + "green": "#A6E22E", + "name": "Monokai", + "purple": "#AE81FF", + "red": "#F92672", + "selectionBackground": "#FFFFFF", + "white": "#F8F8F2", + "yellow": "#FFE792" + }, { "background": "#282C34", "black": "#282C34", @@ -215,7 +271,7 @@ "cyan": "#0997B3", "foreground": "#383A42", "green": "#50A14F", - "name": "One Half Light", + "name": "One Half Dark", "purple": "#A626A4", "red": "#E45649", "selectionBackground": "#FFFFFF", From 1ed3a3681267ad61189e5681196353844f6a4914 Mon Sep 17 00:00:00 2001 From: Dax T Games Date: Tue, 2 Jan 2024 11:41:21 -0500 Subject: [PATCH 12/18] Update windows_terminal_default_settings.json --- vendor/windows_terminal_default_settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/windows_terminal_default_settings.json b/vendor/windows_terminal_default_settings.json index f630811ed..94d9bddc1 100644 --- a/vendor/windows_terminal_default_settings.json +++ b/vendor/windows_terminal_default_settings.json @@ -271,7 +271,7 @@ "cyan": "#0997B3", "foreground": "#383A42", "green": "#50A14F", - "name": "One Half Dark", + "name": "One Half Light", "purple": "#A626A4", "red": "#E45649", "selectionBackground": "#FFFFFF", From c5946422e7f56589cd8fd31dd2013fe81a4f3309 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Thu, 30 May 2024 16:42:48 -0400 Subject: [PATCH 13/18] update build workflow to upload cmder_win.zip --- .github/workflows/build.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6e803e63c..bec247f8c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -52,6 +52,13 @@ jobs: working-directory: scripts run: .\pack.ps1 -verbose -terminal all + - name: Upload artifact (cmder_win.zip) + uses: actions/upload-artifact@v3 + with: + path: build/cmder_win.zip + name: cmder_win.zip + if-no-files-found: error + - name: Upload artifact (cmder_wt.zip) uses: actions/upload-artifact@v3 with: From 9463d4ebc4a828d8f4af0732ce94006cfb7c9092 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Thu, 30 May 2024 17:03:37 -0400 Subject: [PATCH 14/18] update build workflow to upload cmder_win* --- .github/workflows/build.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bec247f8c..382362db0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -52,6 +52,20 @@ jobs: working-directory: scripts run: .\pack.ps1 -verbose -terminal all + - name: Upload artifact (cmder_win_mini.zip) + uses: actions/upload-artifact@v3 + with: + path: build/cmder_win_mini.zip + name: cmder_win_mini.zip + if-no-files-found: error + + - name: Upload artifact (cmder_win.7z) + uses: actions/upload-artifact@v3 + with: + path: build/cmder_win.7z + name: cmder_win.7z + if-no-files-found: error + - name: Upload artifact (cmder_win.zip) uses: actions/upload-artifact@v3 with: From f38e0b3e03353a60fb184929e21537aa254dd0b3 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Thu, 30 May 2024 17:21:29 -0400 Subject: [PATCH 15/18] sync --- vendor/windows_terminal_default_settings.json | 826 ++++++++---------- 1 file changed, 386 insertions(+), 440 deletions(-) diff --git a/vendor/windows_terminal_default_settings.json b/vendor/windows_terminal_default_settings.json index 94d9bddc1..908d25453 100644 --- a/vendor/windows_terminal_default_settings.json +++ b/vendor/windows_terminal_default_settings.json @@ -1,444 +1,390 @@ { - "$help": "https://aka.ms/terminal-documentation", - "$schema": "https://aka.ms/terminal-profiles-schema", - "actions": - [ - { - "command": - { - "action": "copy", - "singleLine": false - }, - "keys": "ctrl+shift+c" - }, - { - "command": "paste" - }, - { - "command": "find", - "keys": "ctrl+shift+f" - }, - { - "command": "unbound", - "keys": "ctrl+v" - }, - { - "command": "unbound", - "keys": "ctrl+c" - }, - { - "command": - { - "action": "splitPane", - "split": "auto", - "splitMode": "duplicate" - }, - "keys": "alt+shift+d" - } - ], - "copyFormatting": "none", - "copyOnSelect": true, - "defaultProfile": "{48946353-ebe8-4571-a591-7d609f31327a}", - "newTabMenu": - [ - { - "type": "remainingProfiles" - } - ], - "profiles": + "$help": "https://aka.ms/terminal-documentation", + "$schema": "https://aka.ms/terminal-profiles-schema", + "actions": [ { - "defaults": - { - "colorScheme": "One Half Dark", - "font": - { - "face": "Cascadia Code" - } - }, - "list": - [ - { - "colorScheme": "One Half Dark", - "commandline": "cmd /k \"%CMDER_ROOT%\\vendor\\init.bat\"", - "guid": "{48946353-ebe8-4571-a591-7d609f31327a}", - "hidden": false, - "icon": "%CMDER_ROOT%\\icons\\cmder.ico", - "name": "Cmder", - "startingDirectory": null, - "tabTitle": "Cmder", - "useAtlasEngine": false - }, - { - "colorScheme": "One Half Dark", - "commandline": "%SystemRoot%\\System32\\cmd.exe /k \"%CMDER_ROOT%\\vendor\\init.bat\"", - "elevate": true, - "guid": "{bdd957d0-c15a-49e6-9816-14b02351a071}", - "hidden": false, - "icon": "%CMDER_ROOT%\\icons\\cmder_red.ico", - "name": "Cmder as Admin", - "startingDirectory": null, - "tabTitle": "Cmder as Admin" - }, - { - "colorScheme": "One Half Dark", - "commandline": "PowerShell -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command \"Invoke-Expression 'Import-Module ''%CMDER_ROOT%\\vendor.\\profile.ps1'''\"", - "guid": "{eb1f6578-ce9d-47a9-a8c7-9b3fdd22302d}", - "hidden": false, - "icon": "%CMDER_ROOT%\\icons\\cmder_orange.ico", - "name": "Cmder - PowerShell", - "startingDirectory": null, - "tabTitle": "Cmder", - "useAtlasEngine": false - }, - { - "colorScheme": "One Half Dark", - "commandline": "PowerShell -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command \"Invoke-Expression 'Import-Module ''%CMDER_ROOT%\\vendor.\\profile.ps1'''\"", - "elevate": true, - "guid": "{c5225c3e-8619-4145-8182-2800814eeb17}", - "hidden": false, - "icon": "%CMDER_ROOT%\\icons\\cmder_purple.ico", - "name": "Cmder - PowerShell as Admin", - "startingDirectory": null, - "tabTitle": "Cmder - PowerShell as Admin", - "useAtlasEngine": false - }, - { - "colorScheme": "One Half Dark", - "commandline": "%CMDER_ROOT%\\vendor\\start_git_bash.cmd", - "guid": "{c5c298e9-010e-4b8c-bc55-e3df81846b4c}", - "hidden": false, - "icon": "%CMDER_ROOT%\\icons\\cmder_blue.ico", - "name": "Cmder - Bash", - "startingDirectory": null, - "tabTitle": "Cmder - Bash" - }, - { - "colorScheme": "One Half Dark", - "commandline": "%CMDER_ROOT%\\vendor\\start_git_bash.cmd", - "elevate": true, - "guid": "{545eb9ed-4c1c-49b3-8cc6-7eb41bd280ff}", - "hidden": false, - "icon": "%CMDER_ROOT%\\icons\\cmder_yellow.ico", - "name": "Cmder - Bash as Admin", - "startingDirectory": null, - "tabTitle": "Cmder - Bash as Admin" - }, - { - "commandline": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", - "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", - "hidden": false, - "name": "Windows PowerShell" - }, - { - "commandline": "%SystemRoot%\\System32\\cmd.exe", - "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", - "hidden": false, - "name": "Command Prompt" - } - - ] + "command": { + "action": "copy", + "singleLine": false + }, + "keys": "ctrl+shift+c" }, - "schemes": - [ - { - "background": "#0C0C0C", - "black": "#0C0C0C", - "blue": "#0037DA", - "brightBlack": "#767676", - "brightBlue": "#3B78FF", - "brightCyan": "#61D6D6", - "brightGreen": "#16C60C", - "brightPurple": "#B4009E", - "brightRed": "#E74856", - "brightWhite": "#F2F2F2", - "brightYellow": "#F9F1A5", - "cursorColor": "#FFFFFF", - "cyan": "#3A96DD", - "foreground": "#CCCCCC", - "green": "#13A10E", - "name": "Campbell", - "purple": "#881798", - "red": "#C50F1F", - "selectionBackground": "#FFFFFF", - "white": "#CCCCCC", - "yellow": "#C19C00" - }, - { - "background": "#012456", - "black": "#0C0C0C", - "blue": "#0037DA", - "brightBlack": "#767676", - "brightBlue": "#3B78FF", - "brightCyan": "#61D6D6", - "brightGreen": "#16C60C", - "brightPurple": "#B4009E", - "brightRed": "#E74856", - "brightWhite": "#F2F2F2", - "brightYellow": "#F9F1A5", - "cursorColor": "#FFFFFF", - "cyan": "#3A96DD", - "foreground": "#CCCCCC", - "green": "#13A10E", - "name": "Campbell Powershell", - "purple": "#881798", - "red": "#C50F1F", - "selectionBackground": "#FFFFFF", - "white": "#CCCCCC", - "yellow": "#C19C00" - }, - { - "background": "#282828", - "black": "#282828", - "blue": "#458588", - "brightBlack": "#928374", - "brightBlue": "#83A598", - "brightCyan": "#8EC07C", - "brightGreen": "#B8BB26", - "brightPurple": "#D3869B", - "brightRed": "#FB4934", - "brightWhite": "#EBDBB2", - "brightYellow": "#FABD2F", - "cursorColor": "#FFFFFF", - "cyan": "#689D6A", - "foreground": "#EBDBB2", - "green": "#98971A", - "name": "Gruvbox Dark", - "purple": "#B16286", - "red": "#CC241D", - "selectionBackground": "#FFFFFF", - "white": "#A89984", - "yellow": "#D79921" - }, - { - "background": "#272822", - "black": "#3E3D32", - "blue": "#03395C", - "brightBlack": "#272822", - "brightBlue": "#66D9EF", - "brightCyan": "#66D9EF", - "brightGreen": "#A6E22E", - "brightPurple": "#AE81FF", - "brightRed": "#F92672", - "brightWhite": "#F8F8F2", - "brightYellow": "#FD971F", - "cursorColor": "#FFFFFF", - "cyan": "#66D9EF", - "foreground": "#F8F8F2", - "green": "#A6E22E", - "name": "Monokai", - "purple": "#AE81FF", - "red": "#F92672", - "selectionBackground": "#FFFFFF", - "white": "#F8F8F2", - "yellow": "#FFE792" - }, - { - "background": "#282C34", - "black": "#282C34", - "blue": "#61AFEF", - "brightBlack": "#5A6374", - "brightBlue": "#61AFEF", - "brightCyan": "#56B6C2", - "brightGreen": "#98C379", - "brightPurple": "#C678DD", - "brightRed": "#E06C75", - "brightWhite": "#DCDFE4", - "brightYellow": "#E5C07B", - "cursorColor": "#FFFFFF", - "cyan": "#56B6C2", - "foreground": "#DCDFE4", - "green": "#98C379", - "name": "One Half Dark", - "purple": "#C678DD", - "red": "#E06C75", - "selectionBackground": "#FFFFFF", - "white": "#DCDFE4", - "yellow": "#E5C07B" - }, - { - "background": "#FAFAFA", - "black": "#383A42", - "blue": "#0184BC", - "brightBlack": "#4F525D", - "brightBlue": "#61AFEF", - "brightCyan": "#56B5C1", - "brightGreen": "#98C379", - "brightPurple": "#C577DD", - "brightRed": "#DF6C75", - "brightWhite": "#FFFFFF", - "brightYellow": "#E4C07A", - "cursorColor": "#4F525D", - "cyan": "#0997B3", - "foreground": "#383A42", - "green": "#50A14F", - "name": "One Half Light", - "purple": "#A626A4", - "red": "#E45649", - "selectionBackground": "#FFFFFF", - "white": "#FAFAFA", - "yellow": "#C18301" - }, - { - "background": "#002B36", - "black": "#002B36", - "blue": "#268BD2", - "brightBlack": "#073642", - "brightBlue": "#839496", - "brightCyan": "#93A1A1", - "brightGreen": "#586E75", - "brightPurple": "#6C71C4", - "brightRed": "#CB4B16", - "brightWhite": "#FDF6E3", - "brightYellow": "#657B83", - "cursorColor": "#FFFFFF", - "cyan": "#2AA198", - "foreground": "#839496", - "green": "#859900", - "name": "Solarized Dark", - "purple": "#D33682", - "red": "#DC322F", - "selectionBackground": "#FFFFFF", - "white": "#EEE8D5", - "yellow": "#B58900" - }, - { - "background": "#FDF6E3", - "black": "#002B36", - "blue": "#268BD2", - "brightBlack": "#073642", - "brightBlue": "#839496", - "brightCyan": "#93A1A1", - "brightGreen": "#586E75", - "brightPurple": "#6C71C4", - "brightRed": "#CB4B16", - "brightWhite": "#FDF6E3", - "brightYellow": "#657B83", - "cursorColor": "#002B36", - "cyan": "#2AA198", - "foreground": "#657B83", - "green": "#859900", - "name": "Solarized Light", - "purple": "#D33682", - "red": "#DC322F", - "selectionBackground": "#FFFFFF", - "white": "#EEE8D5", - "yellow": "#B58900" - }, - { - "background": "#000000", - "black": "#000000", - "blue": "#3465A4", - "brightBlack": "#555753", - "brightBlue": "#729FCF", - "brightCyan": "#34E2E2", - "brightGreen": "#8AE234", - "brightPurple": "#AD7FA8", - "brightRed": "#EF2929", - "brightWhite": "#EEEEEC", - "brightYellow": "#FCE94F", - "cursorColor": "#FFFFFF", - "cyan": "#06989A", - "foreground": "#D3D7CF", - "green": "#4E9A06", - "name": "Tango Dark", - "purple": "#75507B", - "red": "#CC0000", - "selectionBackground": "#FFFFFF", - "white": "#D3D7CF", - "yellow": "#C4A000" - }, - { - "background": "#FFFFFF", - "black": "#000000", - "blue": "#3465A4", - "brightBlack": "#555753", - "brightBlue": "#729FCF", - "brightCyan": "#34E2E2", - "brightGreen": "#8AE234", - "brightPurple": "#AD7FA8", - "brightRed": "#EF2929", - "brightWhite": "#EEEEEC", - "brightYellow": "#FCE94F", - "cursorColor": "#000000", - "cyan": "#06989A", - "foreground": "#555753", - "green": "#4E9A06", - "name": "Tango Light", - "purple": "#75507B", - "red": "#CC0000", - "selectionBackground": "#FFFFFF", - "white": "#D3D7CF", - "yellow": "#C4A000" - }, - { - "background": "#000000", - "black": "#000000", - "blue": "#000080", - "brightBlack": "#808080", - "brightBlue": "#0000FF", - "brightCyan": "#00FFFF", - "brightGreen": "#00FF00", - "brightPurple": "#FF00FF", - "brightRed": "#FF0000", - "brightWhite": "#FFFFFF", - "brightYellow": "#FFFF00", - "cursorColor": "#FFFFFF", - "cyan": "#008080", - "foreground": "#C0C0C0", - "green": "#008000", - "name": "Vintage", - "purple": "#800080", - "red": "#800000", - "selectionBackground": "#FFFFFF", - "white": "#C0C0C0", - "yellow": "#808000" - } - ], - "themes": - [ - { - "name": "legacyDark", - "tab": - { - "background": null, - "showCloseButton": "always", - "unfocusedBackground": null - }, - "window": - { - "applicationTheme": "dark", - "useMica": false - } - }, - { - "name": "legacyLight", - "tab": - { - "background": null, - "showCloseButton": "always", - "unfocusedBackground": null - }, - "window": - { - "applicationTheme": "light", - "useMica": false - } - }, - { - "name": "legacySystem", - "tab": - { - "background": null, - "showCloseButton": "always", - "unfocusedBackground": null - }, - "window": - { - "applicationTheme": "system", - "useMica": false - } - } - ], - "useAcrylicInTabRow": true, - "wordDelimiters": " ()\"',;<>!@#$%^&*|+=[]{}~?\u2502" + { + "command": "unbound", + "keys": "ctrl+v" + }, + { + "command": "unbound", + "keys": "ctrl+c" + }, + { + "command": "paste" + }, + { + "command": "find", + "keys": "ctrl+shift+f" + }, + { + "command": { + "action": "splitPane", + "split": "auto", + "splitMode": "duplicate" + }, + "keys": "alt+shift+d" + } + ], + "copyFormatting": "none", + "copyOnSelect": true, + "defaultProfile": "{48946353-ebe8-4571-a591-7d609f31327a}", + "newTabMenu": [ + { + "type": "remainingProfiles" + } + ], + "profiles": { + "defaults": { + "colorScheme": "One Half Dark", + "font": { + "face": "Cascadia Code" + } + }, + "list": [ + { + "colorScheme": "One Half Dark", + "commandline": "cmd /k \"%WT_SETTINGS_DIR%\\..\\..\\init.bat\"", + "guid": "{48946353-ebe8-4571-a591-7d609f31327a}", + "hidden": false, + "icon": "%WT_SETTINGS_DIR%\\..\\..\\..\\icons\\cmder.ico", + "name": "Cmder", + "startingDirectory": null, + "tabTitle": "Cmder", + "useAtlasEngine": false + }, + { + "colorScheme": "One Half Dark", + "commandline": "%SystemRoot%\\System32\\cmd.exe /k \"%WT_SETTINGS_DIR%\\..\\..\\init.bat\"", + "elevate": true, + "guid": "{bdd957d0-c15a-49e6-9816-14b02351a071}", + "hidden": false, + "icon": "%WT_SETTINGS_DIR%\\..\\..\\..\\icons\\cmder_red.ico", + "name": "Cmder as Admin", + "startingDirectory": null, + "tabTitle": "Cmder as Admin" + }, + { + "colorScheme": "One Half Dark", + "commandline": "PowerShell -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command \"Invoke-Expression 'Import-Module ''%WT_SETTINGS_DIR%\\..\\..\\profile.ps1'''\"", + "guid": "{eb1f6578-ce9d-47a9-a8c7-9b3fdd22302d}", + "hidden": false, + "icon": "%WT_SETTINGS_DIR%\\..\\..\\..\\icons\\cmder_orange.ico", + "name": "Cmder - PowerShell", + "startingDirectory": null, + "tabTitle": "Cmder", + "useAtlasEngine": false + }, + { + "colorScheme": "One Half Dark", + "commandline": "PowerShell -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command \"Invoke-Expression 'Import-Module ''%WT_SETTINGS_DIR%\\..\\..\\profile.ps1'''\"", + "elevate": true, + "guid": "{c5225c3e-8619-4145-8182-2800814eeb17}", + "hidden": false, + "icon": "%WT_SETTINGS_DIR%\\..\\..\\..\\icons\\cmder_purple.ico", + "name": "Cmder - PowerShell as Admin", + "startingDirectory": null, + "tabTitle": "Cmder - PowerShell as Admin", + "useAtlasEngine": false + }, + { + "colorScheme": "One Half Dark", + "commandline": "%WT_SETTINGS_DIR%\\..\\..\\start_git_bash.cmd", + "guid": "{c5c298e9-010e-4b8c-bc55-e3df81846b4c}", + "hidden": false, + "icon": "%WT_SETTINGS_DIR%\\..\\..\\..\\icons\\cmder_blue.ico", + "name": "Cmder - Bash", + "startingDirectory": null, + "tabTitle": "Cmder - Bash" + }, + { + "colorScheme": "One Half Dark", + "commandline": "%WT_SETTINGS_DIR%\\..\\..\\start_git_bash.cmd", + "elevate": true, + "guid": "{545eb9ed-4c1c-49b3-8cc6-7eb41bd280ff}", + "hidden": false, + "icon": "%WT_SETTINGS_DIR%\\..\\..\\..\\icons\\cmder_yellow.ico", + "name": "Cmder - Bash as Admin", + "startingDirectory": null, + "tabTitle": "Cmder - Bash as Admin" + }, + { + "commandline": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", + "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", + "hidden": false, + "name": "Windows PowerShell" + }, + { + "commandline": "%SystemRoot%\\System32\\cmd.exe", + "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", + "hidden": false, + "name": "Command Prompt" + } + ] + }, + "schemes": [ + { + "background": "#0C0C0C", + "black": "#0C0C0C", + "blue": "#0037DA", + "brightBlack": "#767676", + "brightBlue": "#3B78FF", + "brightCyan": "#61D6D6", + "brightGreen": "#16C60C", + "brightPurple": "#B4009E", + "brightRed": "#E74856", + "brightWhite": "#F2F2F2", + "brightYellow": "#F9F1A5", + "cursorColor": "#FFFFFF", + "cyan": "#3A96DD", + "foreground": "#CCCCCC", + "green": "#13A10E", + "name": "Campbell", + "purple": "#881798", + "red": "#C50F1F", + "selectionBackground": "#FFFFFF", + "white": "#CCCCCC", + "yellow": "#C19C00" + }, + { + "background": "#012456", + "black": "#0C0C0C", + "blue": "#0037DA", + "brightBlack": "#767676", + "brightBlue": "#3B78FF", + "brightCyan": "#61D6D6", + "brightGreen": "#16C60C", + "brightPurple": "#B4009E", + "brightRed": "#E74856", + "brightWhite": "#F2F2F2", + "brightYellow": "#F9F1A5", + "cursorColor": "#FFFFFF", + "cyan": "#3A96DD", + "foreground": "#CCCCCC", + "green": "#13A10E", + "name": "Campbell Powershell", + "purple": "#881798", + "red": "#C50F1F", + "selectionBackground": "#FFFFFF", + "white": "#CCCCCC", + "yellow": "#C19C00" + }, + { + "background": "#282828", + "black": "#282828", + "blue": "#458588", + "brightBlack": "#928374", + "brightBlue": "#83A598", + "brightCyan": "#8EC07C", + "brightGreen": "#B8BB26", + "brightPurple": "#D3869B", + "brightRed": "#FB4934", + "brightWhite": "#EBDBB2", + "brightYellow": "#FABD2F", + "cursorColor": "#FFFFFF", + "cyan": "#689D6A", + "foreground": "#EBDBB2", + "green": "#98971A", + "name": "Gruvbox Dark", + "purple": "#B16286", + "red": "#CC241D", + "selectionBackground": "#FFFFFF", + "white": "#A89984", + "yellow": "#D79921" + }, + { + "background": "#272822", + "black": "#3E3D32", + "blue": "#03395C", + "brightBlack": "#272822", + "brightBlue": "#66D9EF", + "brightCyan": "#66D9EF", + "brightGreen": "#A6E22E", + "brightPurple": "#AE81FF", + "brightRed": "#F92672", + "brightWhite": "#F8F8F2", + "brightYellow": "#FD971F", + "cursorColor": "#FFFFFF", + "cyan": "#66D9EF", + "foreground": "#F8F8F2", + "green": "#A6E22E", + "name": "Monokai", + "purple": "#AE81FF", + "red": "#F92672", + "selectionBackground": "#FFFFFF", + "white": "#F8F8F2", + "yellow": "#FFE792" + }, + { + "background": "#282C34", + "black": "#282C34", + "blue": "#61AFEF", + "brightBlack": "#5A6374", + "brightBlue": "#61AFEF", + "brightCyan": "#56B6C2", + "brightGreen": "#98C379", + "brightPurple": "#C678DD", + "brightRed": "#E06C75", + "brightWhite": "#DCDFE4", + "brightYellow": "#E5C07B", + "cursorColor": "#FFFFFF", + "cyan": "#56B6C2", + "foreground": "#DCDFE4", + "green": "#98C379", + "name": "One Half Dark", + "purple": "#C678DD", + "red": "#E06C75", + "selectionBackground": "#FFFFFF", + "white": "#DCDFE4", + "yellow": "#E5C07B" + }, + { + "background": "#FAFAFA", + "black": "#383A42", + "blue": "#0184BC", + "brightBlack": "#4F525D", + "brightBlue": "#61AFEF", + "brightCyan": "#56B5C1", + "brightGreen": "#98C379", + "brightPurple": "#C577DD", + "brightRed": "#DF6C75", + "brightWhite": "#FFFFFF", + "brightYellow": "#E4C07A", + "cursorColor": "#4F525D", + "cyan": "#0997B3", + "foreground": "#383A42", + "green": "#50A14F", + "name": "One Half Light", + "purple": "#A626A4", + "red": "#E45649", + "selectionBackground": "#FFFFFF", + "white": "#FAFAFA", + "yellow": "#C18301" + }, + { + "background": "#002B36", + "black": "#002B36", + "blue": "#268BD2", + "brightBlack": "#073642", + "brightBlue": "#839496", + "brightCyan": "#93A1A1", + "brightGreen": "#586E75", + "brightPurple": "#6C71C4", + "brightRed": "#CB4B16", + "brightWhite": "#FDF6E3", + "brightYellow": "#657B83", + "cursorColor": "#FFFFFF", + "cyan": "#2AA198", + "foreground": "#839496", + "green": "#859900", + "name": "Solarized Dark", + "purple": "#D33682", + "red": "#DC322F", + "selectionBackground": "#FFFFFF", + "white": "#EEE8D5", + "yellow": "#B58900" + }, + { + "background": "#FDF6E3", + "black": "#002B36", + "blue": "#268BD2", + "brightBlack": "#073642", + "brightBlue": "#839496", + "brightCyan": "#93A1A1", + "brightGreen": "#586E75", + "brightPurple": "#6C71C4", + "brightRed": "#CB4B16", + "brightWhite": "#FDF6E3", + "brightYellow": "#657B83", + "cursorColor": "#002B36", + "cyan": "#2AA198", + "foreground": "#657B83", + "green": "#859900", + "name": "Solarized Light", + "purple": "#D33682", + "red": "#DC322F", + "selectionBackground": "#FFFFFF", + "white": "#EEE8D5", + "yellow": "#B58900" + }, + { + "background": "#000000", + "black": "#000000", + "blue": "#3465A4", + "brightBlack": "#555753", + "brightBlue": "#729FCF", + "brightCyan": "#34E2E2", + "brightGreen": "#8AE234", + "brightPurple": "#AD7FA8", + "brightRed": "#EF2929", + "brightWhite": "#EEEEEC", + "brightYellow": "#FCE94F", + "cursorColor": "#FFFFFF", + "cyan": "#06989A", + "foreground": "#D3D7CF", + "green": "#4E9A06", + "name": "Tango Dark", + "purple": "#75507B", + "red": "#CC0000", + "selectionBackground": "#FFFFFF", + "white": "#D3D7CF", + "yellow": "#C4A000" + }, + { + "background": "#FFFFFF", + "black": "#000000", + "blue": "#3465A4", + "brightBlack": "#555753", + "brightBlue": "#729FCF", + "brightCyan": "#34E2E2", + "brightGreen": "#8AE234", + "brightPurple": "#AD7FA8", + "brightRed": "#EF2929", + "brightWhite": "#EEEEEC", + "brightYellow": "#FCE94F", + "cursorColor": "#000000", + "cyan": "#06989A", + "foreground": "#555753", + "green": "#4E9A06", + "name": "Tango Light", + "purple": "#75507B", + "red": "#CC0000", + "selectionBackground": "#FFFFFF", + "white": "#D3D7CF", + "yellow": "#C4A000" + }, + { + "background": "#000000", + "black": "#000000", + "blue": "#000080", + "brightBlack": "#808080", + "brightBlue": "#0000FF", + "brightCyan": "#00FFFF", + "brightGreen": "#00FF00", + "brightPurple": "#FF00FF", + "brightRed": "#FF0000", + "brightWhite": "#FFFFFF", + "brightYellow": "#FFFF00", + "cursorColor": "#FFFFFF", + "cyan": "#008080", + "foreground": "#C0C0C0", + "green": "#008000", + "name": "Vintage", + "purple": "#800080", + "red": "#800000", + "selectionBackground": "#FFFFFF", + "white": "#C0C0C0", + "yellow": "#808000" + } + ], + "themes": [], + "useAcrylicInTabRow": true, + "wordDelimiters": " ()\"',;<>!@#$%^&*|+=[]{}~?\u2502" } From 2e945fb02b59feada837852007f0c678585f46f9 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Fri, 31 May 2024 18:31:16 -0400 Subject: [PATCH 16/18] Fix launcher overwritting/backing up emulator settings --- launcher/src/CmderLauncher.cpp | 119 ++++++++++++++++++--------------- 1 file changed, 66 insertions(+), 53 deletions(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index b0e8c91ce..055f7db1c 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -290,60 +290,66 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr PathCombine(userCfgPath, userConfigDirPath, L"user-ConEmu.xml"); } - if (wcscmp(cpuCfgPath, L"") == 0 && (PathFileExists(cpuCfgPath) || use_user_cfg == false)) // config/ConEmu-%COMPUTERNAME%.xml file exists or /m was specified on command line, use machine specific config. + if ( PathFileExists(cpuCfgPath) || use_user_cfg == false ) // config/[cpu specific terminal emulator config] file exists or /m was specified on command line, use machine specific config. { if (cfgRoot.length() == 0) // '/c [path]' was NOT specified { - if (!CopyFile(cfgPath, cpuCfgPath, FALSE)) + if (PathFileExists(cfgPath)) // [terminal emulator config] file exists, copy [terminal emulator config] to config/user_[terminal emulator config] file to backup any settings changes from previous sessions. { - if (PathFileExists(windowsTerminalDir)) { - MessageBox(NULL, - (GetLastError() == ERROR_ACCESS_DENIED) - ? L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/windows_terminal_%COMPUTERNAME%_settings.json! Access Denied." - : L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/windows_teerminal_%COMPUTERNAME%_settigns.json!", MB_TITLE, MB_ICONSTOP); - exit(1); - } - else if (PathFileExists(conEmuDir)) + if (!CopyFile(cfgPath, cpuCfgPath, FALSE)) { - MessageBox(NULL, - (GetLastError() == ERROR_ACCESS_DENIED) - ? L"Failed to copy vendor/conemu-maximus5/ConEmu.xml file to config/ConEmu-%COMPUTERNAME%.xml! Access Denied." - : L"Failed to copy vendor/conemu-maximus5/ConEmu.xml file to config/ConEmu-%COMPUTERNAME%.xml!", MB_TITLE, MB_ICONSTOP); - exit(1); + if (PathFileExists(windowsTerminalDir)) + { + MessageBox(NULL, + (GetLastError() == ERROR_ACCESS_DENIED) + ? L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/windows_terminal_%COMPUTERNAME%_settings.json! Access Denied." + : L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/windows_teerminal_%COMPUTERNAME%_settigns.json!", MB_TITLE, MB_ICONSTOP); + exit(1); + } + else if (PathFileExists(conEmuDir)) + { + MessageBox(NULL, + (GetLastError() == ERROR_ACCESS_DENIED) + ? L"Failed to copy vendor/conemu-maximus5/ConEmu.xml file to config/ConEmu-%COMPUTERNAME%.xml! Access Denied." + : L"Failed to copy vendor/conemu-maximus5/ConEmu.xml file to config/ConEmu-%COMPUTERNAME%.xml!", MB_TITLE, MB_ICONSTOP); + exit(1); + } } } - } - else // vendor/conemu-maximus5/ConEmu.xml config file does not exist, copy config/ConEmu-%COMPUTERNAME%.xml to vendor/conemu-maximus5/ConEmu.xml file - { - if (!CopyFile(cpuCfgPath, cfgPath, FALSE)) + else // [terminal emulator config] file does not exist, copy config/[cpu specific terminal emulator config] file to [terminal emulator config] file { - if (PathFileExists(windowsTerminalDir)) { - MessageBox(NULL, - (GetLastError() == ERROR_ACCESS_DENIED) - ? L"Failed to copy config/windows_terminal_%COMPUTERNAME%_settings.json file to vendor/windows-terminal/settings/settings.json! Access Denied." - : L"Failed to copy config/windows_terminal_%COMPUTERNAME%_settings.json file to vendor/windows-terminal/settings/settings.json!", MB_TITLE, MB_ICONSTOP); - exit(1); - } - else if (PathFileExists(conEmuDir)) + if (!CopyFile(cpuCfgPath, cfgPath, FALSE)) { - MessageBox(NULL, - (GetLastError() == ERROR_ACCESS_DENIED) - ? L"Failed to copy config/ConEmu-%COMPUTERNAME%.xml file to vendor/conemu-maximus5/ConEmu.xml! Access Denied." - : L"Failed to copy config/ConEmu-%COMPUTERNAME%.xml file to vendor/conemu-maximus5/ConEmu.xml!", MB_TITLE, MB_ICONSTOP); - exit(1); + if (PathFileExists(windowsTerminalDir)) + { + MessageBox(NULL, + (GetLastError() == ERROR_ACCESS_DENIED) + ? L"Failed to copy config/windows_terminal_%COMPUTERNAME%_settings.json file to vendor/windows-terminal/settings/settings.json! Access Denied." + : L"Failed to copy config/windows_terminal_%COMPUTERNAME%_settings.json file to vendor/windows-terminal/settings/settings.json!", MB_TITLE, MB_ICONSTOP); + exit(1); + } + else if (PathFileExists(conEmuDir)) + { + MessageBox(NULL, + (GetLastError() == ERROR_ACCESS_DENIED) + ? L"Failed to copy config/ConEmu-%COMPUTERNAME%.xml file to vendor/conemu-maximus5/ConEmu.xml! Access Denied." + : L"Failed to copy config/ConEmu-%COMPUTERNAME%.xml file to vendor/conemu-maximus5/ConEmu.xml!", MB_TITLE, MB_ICONSTOP); + exit(1); + } } } } } - else if (wcscmp(userCfgPath, L"") == 0 && PathFileExists(userCfgPath)) // config/user_conemu.xml exists, use it. + else if (PathFileExists(userCfgPath)) // config/user[terminal emulator config] file exists, use it. { if (cfgRoot.length() == 0) // '/c [path]' was NOT specified { - if (PathFileExists(cfgPath)) // vendor/conemu-maximus5/ConEmu.xml exists, copy vendor/conemu-maximus5/ConEmu.xml to config/user_conemu.xml. + if (PathFileExists(cfgPath)) // [terminal emulator config] file exists, copy [terminal emulator config] to config/user_[terminal emulator config] file to backup any settings changes from previous sessions. { if (!CopyFile(cfgPath, userCfgPath, FALSE)) { - if (PathFileExists(windowsTerminalDir)) { + if (PathFileExists(windowsTerminalDir)) + { MessageBox(NULL, (GetLastError() == ERROR_ACCESS_DENIED) ? L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/windows_terminal_settings.json! Access Denied." @@ -360,11 +366,12 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr } } } - else // vendor/conemu-maximus5/ConEmu.xml does not exist, copy config/user-conemu.xml to vendor/conemu-maximus5/ConEmu.xml + else // [terminal emulator config] file does not exist, copy config/user_[terminal emulator config] file to [terminal emulator config] file { if (!CopyFile(userCfgPath, cfgPath, FALSE)) { - if (PathFileExists(windowsTerminalDir)) { + if (PathFileExists(windowsTerminalDir)) + { MessageBox(NULL, (GetLastError() == ERROR_ACCESS_DENIED) ? L"Failed to copy config/user_windows_terminal_settings.json file to vendor/windows-terminal/settings/settings.json! Access Denied." @@ -382,17 +389,18 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr } } } - else if (!PathFileExists(windowsTerminalDir)) { // '/c [path]' was specified, don't copy anything and use existing user_conemu.xml to start comemu. + else if (!PathFileExists(windowsTerminalDir)) { // '/c [path]' was specified, don't copy anything and use existing user_[terminal emulator config] file. PathCombine(userConEmuCfgPath, userConfigDirPath, L"user-ConEmu.xml"); } } else if (cfgRoot.length() == 0) // '/c [path]' was NOT specified { - if (PathFileExists(cfgPath)) // vendor/conemu-maximus5/ConEmu.xml exists, copy vendor/conemu-maximus5/ConEmu.xml to config/user_conemu.xml + if (PathFileExists(cfgPath)) // [terminal emulator config] file exists, copy [terminal emulator config] file to config/user_[terminal emulator config] file. { if (!CopyFile(cfgPath, userCfgPath, FALSE)) { - if (PathFileExists(windowsTerminalDir)) { + if (PathFileExists(windowsTerminalDir)) + { MessageBox(NULL, (GetLastError() == ERROR_ACCESS_DENIED) ? L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/user_windows_terminal_settings.json! Access Denied." @@ -408,11 +416,12 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr exit(1); } } - else // vendor/ConEmu.xml.default config exists, copy Cmder vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml. + else // vendor/[terminal emulator config].default config exists, copy Cmder vendor/[terminal emulator config].default file to [terminal emulator config] file. { if (!CopyFile(defaultCfgPath, cfgPath, FALSE)) { - if (PathFileExists(windowsTerminalDir)) { + if (PathFileExists(windowsTerminalDir)) + { MessageBox(NULL, (GetLastError() == ERROR_ACCESS_DENIED) ? L"Failed to copy vendor/windows-terminal_default_settings_settings.json file to vendor/windows-terminal/settings/settings.json! Access Denied." @@ -430,20 +439,23 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr } } } - else if (!CopyFile(defaultCfgPath, cfgPath, FALSE) && PathFileExists(conEmuDir)) - { - MessageBox(NULL, - (GetLastError() == ERROR_ACCESS_DENIED) - ? L"Failed to copy vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml! Access Denied." - : L"Failed to copy vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml!", MB_TITLE, MB_ICONSTOP); - exit(1); + else { + if (!CopyFile(defaultCfgPath, cfgPath, FALSE) && PathFileExists(conEmuDir)) + { + MessageBox(NULL, + (GetLastError() == ERROR_ACCESS_DENIED) + ? L"Failed to copy vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml! Access Denied." + : L"Failed to copy vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml!", MB_TITLE, MB_ICONSTOP); + exit(1); + } } } - else if (wcscmp(cfgPath, L"") == 0 && PathFileExists(cfgPath)) // vendor/conemu-maximus5/ConEmu.xml exists, copy vendor/conemu-maximus5/ConEmu.xml to config/user_conemu.xml + else if (PathFileExists(cfgPath)) // This is a first time Cmder.exe run and [terminal emulator config] file exists, copy [terminal emulator config] file to config/user_[terminal emulator config] file. { if (!CopyFile(cfgPath, userCfgPath, FALSE)) { - if (PathFileExists(windowsTerminalDir)) { + if (PathFileExists(windowsTerminalDir)) + { MessageBox(NULL, (GetLastError() == ERROR_ACCESS_DENIED) ? L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/user_windows_terminal_settings_settings.json! Access Denied." @@ -462,11 +474,12 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr PathCombine(userConEmuCfgPath, userConfigDirPath, L"user-ConEmu.xml"); } - else if (wcscmp(defaultCfgPath, L"") == 0) // '/c [path]' was specified and 'vendor/ConEmu.xml.default' config exists, copy Cmder 'vendor/ConEmu.xml.default' file to '[user specified path]/config/user_ConEmu.xml'. + else if (wcscmp(defaultCfgPath, L"") == 0) // '/c [path]' was specified and 'vendor/[terminal emulator config].default' config exists, copy Cmder 'vendor/[terminal emulator config].default' file to '[user specified path]/config/user_[terminal emulator config]'. { if ( ! CopyFile(defaultCfgPath, userCfgPath, FALSE)) { - if (PathFileExists(windowsTerminalDir)) { + if (PathFileExists(windowsTerminalDir)) + { MessageBox(NULL, (GetLastError() == ERROR_ACCESS_DENIED) ? L"Failed to copy vendor/windows-terminal_default_settings_settings.json file to [user specified path]/config/user_windows_terminal_settings.json! Access Denied." From 82ab068f12ecf7f020ac8d4365d1f1408c8f2e23 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Thu, 15 Aug 2024 10:24:02 -0400 Subject: [PATCH 17/18] cleanup --- launcher/src/CmderLauncher.cpp | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index 055f7db1c..e1aa2d559 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -298,8 +298,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr { if (!CopyFile(cfgPath, cpuCfgPath, FALSE)) { - if (PathFileExists(windowsTerminalDir)) - { + if (PathFileExists(windowsTerminalDir)) { MessageBox(NULL, (GetLastError() == ERROR_ACCESS_DENIED) ? L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/windows_terminal_%COMPUTERNAME%_settings.json! Access Denied." @@ -320,8 +319,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr { if (!CopyFile(cpuCfgPath, cfgPath, FALSE)) { - if (PathFileExists(windowsTerminalDir)) - { + if (PathFileExists(windowsTerminalDir)) { MessageBox(NULL, (GetLastError() == ERROR_ACCESS_DENIED) ? L"Failed to copy config/windows_terminal_%COMPUTERNAME%_settings.json file to vendor/windows-terminal/settings/settings.json! Access Denied." @@ -348,8 +346,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr { if (!CopyFile(cfgPath, userCfgPath, FALSE)) { - if (PathFileExists(windowsTerminalDir)) - { + if (PathFileExists(windowsTerminalDir)) { MessageBox(NULL, (GetLastError() == ERROR_ACCESS_DENIED) ? L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/windows_terminal_settings.json! Access Denied." @@ -370,8 +367,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr { if (!CopyFile(userCfgPath, cfgPath, FALSE)) { - if (PathFileExists(windowsTerminalDir)) - { + if (PathFileExists(windowsTerminalDir)) { MessageBox(NULL, (GetLastError() == ERROR_ACCESS_DENIED) ? L"Failed to copy config/user_windows_terminal_settings.json file to vendor/windows-terminal/settings/settings.json! Access Denied." @@ -399,8 +395,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr { if (!CopyFile(cfgPath, userCfgPath, FALSE)) { - if (PathFileExists(windowsTerminalDir)) - { + if (PathFileExists(windowsTerminalDir)) { MessageBox(NULL, (GetLastError() == ERROR_ACCESS_DENIED) ? L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/user_windows_terminal_settings.json! Access Denied." @@ -420,8 +415,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr { if (!CopyFile(defaultCfgPath, cfgPath, FALSE)) { - if (PathFileExists(windowsTerminalDir)) - { + if (PathFileExists(windowsTerminalDir)) { MessageBox(NULL, (GetLastError() == ERROR_ACCESS_DENIED) ? L"Failed to copy vendor/windows-terminal_default_settings_settings.json file to vendor/windows-terminal/settings/settings.json! Access Denied." @@ -439,8 +433,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr } } } - else { - if (!CopyFile(defaultCfgPath, cfgPath, FALSE) && PathFileExists(conEmuDir)) + else if (!CopyFile(defaultCfgPath, cfgPath, FALSE) && PathFileExists(conEmuDir)) { MessageBox(NULL, (GetLastError() == ERROR_ACCESS_DENIED) @@ -454,8 +447,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr { if (!CopyFile(cfgPath, userCfgPath, FALSE)) { - if (PathFileExists(windowsTerminalDir)) - { + if (PathFileExists(windowsTerminalDir)) { MessageBox(NULL, (GetLastError() == ERROR_ACCESS_DENIED) ? L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/user_windows_terminal_settings_settings.json! Access Denied." @@ -478,8 +470,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr { if ( ! CopyFile(defaultCfgPath, userCfgPath, FALSE)) { - if (PathFileExists(windowsTerminalDir)) - { + if (PathFileExists(windowsTerminalDir)) { MessageBox(NULL, (GetLastError() == ERROR_ACCESS_DENIED) ? L"Failed to copy vendor/windows-terminal_default_settings_settings.json file to [user specified path]/config/user_windows_terminal_settings.json! Access Denied." From f4f6255c1a9dd16b2e0fa68c469790842e07fe8e Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Tue, 20 Aug 2024 12:25:33 +0000 Subject: [PATCH 18/18] remove extra {} --- launcher/src/CmderLauncher.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index e1aa2d559..1a70b4a09 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -434,13 +434,12 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr } } else if (!CopyFile(defaultCfgPath, cfgPath, FALSE) && PathFileExists(conEmuDir)) - { - MessageBox(NULL, - (GetLastError() == ERROR_ACCESS_DENIED) - ? L"Failed to copy vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml! Access Denied." - : L"Failed to copy vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml!", MB_TITLE, MB_ICONSTOP); - exit(1); - } + { + MessageBox(NULL, + (GetLastError() == ERROR_ACCESS_DENIED) + ? L"Failed to copy vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml! Access Denied." + : L"Failed to copy vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml!", MB_TITLE, MB_ICONSTOP); + exit(1); } } else if (PathFileExists(cfgPath)) // This is a first time Cmder.exe run and [terminal emulator config] file exists, copy [terminal emulator config] file to config/user_[terminal emulator config] file. @@ -468,7 +467,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr } else if (wcscmp(defaultCfgPath, L"") == 0) // '/c [path]' was specified and 'vendor/[terminal emulator config].default' config exists, copy Cmder 'vendor/[terminal emulator config].default' file to '[user specified path]/config/user_[terminal emulator config]'. { - if ( ! CopyFile(defaultCfgPath, userCfgPath, FALSE)) +if ( ! CopyFile(defaultCfgPath, userCfgPath, FALSE)) { if (PathFileExists(windowsTerminalDir)) { MessageBox(NULL,