Skip to content

Commit 637b0fd

Browse files
daxgamesStanzilla
authored andcommitted
Ignore %cmder_root%\config (#1945)
* move default comemu.xml to vendor folder * ignore all of config folder * cleanup
1 parent a5bdecc commit 637b0fd

File tree

3 files changed

+71
-34
lines changed

3 files changed

+71
-34
lines changed

.gitignore

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
11

22
## Those files should be taken from their repositary
33

4-
bin/*/*
4+
bin/*
55
!bin/Readme.md
6+
67
vendor/*/*
78
!vendor/bin/*
89
!vendor/lib/*
910
!vendor/*
1011
!vendor/psmodules/PsGet
1112

12-
config/.history
13+
config/*
14+
!config/Readme.md
15+
1316
Thumbs.db
1417
*.exe
1518
*.dll
1619
build/
1720
Version v*
1821
*.bak
19-
config/user-*
20-
config/user_*
21-
config/*.lua
22-
config/settings
23-
config/aliases
24-
config/profile.d
2522
.github_changelog_generator
2623
launcher/.vs
2724
launcher/src/version.rc2

launcher/src/CmderLauncher.cpp

Lines changed: 66 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,12 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
110110

111111
PathCombine(configDirPath, exeDir, L"config");
112112

113+
/*
114+
Convert legacy user-profile.cmd to new name user_profile.cmd
115+
*/
113116
PathCombine(legacyUserProfilePath, configDirPath, L"user-profile.cmd");
114-
if (PathFileExists(legacyUserProfilePath)) {
117+
if (PathFileExists(legacyUserProfilePath))
118+
{
115119
PathCombine(userProfilePath, configDirPath, L"user_profile.cmd");
116120

117121
char *lPr = (char *)malloc(MAX_PATH);
@@ -124,8 +128,12 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
124128
rename(lPr, pR);
125129
}
126130

131+
/*
132+
Convert legacy user-aliases.cmd to new name user_aliases.cmd
133+
*/
127134
PathCombine(legacyUserAliasesPath, configDirPath, L"user-aliases.cmd");
128-
if (PathFileExists(legacyUserAliasesPath)) {
135+
if (PathFileExists(legacyUserAliasesPath))
136+
{
129137
PathCombine(userAliasesPath, configDirPath, L"user_aliases.cmd");
130138

131139
char *lPr = (char *)malloc(MAX_PATH);
@@ -137,13 +145,18 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
137145
userAliasesPath, (size_t)MAX_PATH);
138146
rename(lPr, pR);
139147
}
140-
148+
149+
/*
150+
Was -c [path] specified?
151+
*/
141152
if (wcscmp(userConfigDirPath, L"") == 0)
142153
{
154+
// No - It wasn't.
143155
PathCombine(userConfigDirPath, exeDir, L"config");
144156
}
145157
else
146158
{
159+
// Yes - It was.
147160
PathCombine(userBinDirPath, userConfigDirPath, L"bin");
148161
SHCreateDirectoryEx(0, userBinDirPath, 0);
149162

@@ -152,9 +165,13 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
152165

153166
PathCombine(userProfiledDirPath, userConfigDirPath, L"profile.d");
154167
SHCreateDirectoryEx(0, userProfiledDirPath, 0);
155-
168+
169+
/*
170+
Convert legacy user-profile.cmd to new name user_profile.cmd
171+
*/
156172
PathCombine(legacyUserProfilePath, userConfigDirPath, L"user-profile.cmd");
157-
if (PathFileExists(legacyUserProfilePath)) {
173+
if (PathFileExists(legacyUserProfilePath))
174+
{
158175
PathCombine(userProfilePath, userConfigDirPath, L"user_profile.cmd");
159176

160177
char *lPr = (char *)malloc(MAX_PATH);
@@ -167,8 +184,12 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
167184
rename(lPr, pR);
168185
}
169186

187+
/*
188+
Convert legacy user-aliases.cmd to new name user_aliases.cmd
189+
*/
170190
PathCombine(legacyUserAliasesPath, userConfigDirPath, L"user-aliases.cmd");
171-
if (PathFileExists(legacyUserAliasesPath)) {
191+
if (PathFileExists(legacyUserAliasesPath))
192+
{
172193
PathCombine(userAliasesPath, userConfigDirPath, L"user_aliases.cmd");
173194

174195
char *lPr = (char *)malloc(MAX_PATH);
@@ -186,15 +207,19 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
186207
PathCombine(cfgPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.xml");
187208

188209
// Set path to Cmder default ConEmu config file
189-
PathCombine(defaultCfgPath, exeDir, L"config\\ConEmu.xml");
210+
PathCombine(defaultCfgPath, exeDir, L"config\\vendor\\ConEmu.xml.default");
190211

191212
// Check for machine-specific then user config source file.
192213
PathCombine(cpuCfgPath, userConfigDirPath, L"ConEmu-%COMPUTERNAME%.xml");
193214
ExpandEnvironmentStrings(cpuCfgPath, cpuCfgPath, sizeof(cpuCfgPath) / sizeof(cpuCfgPath[0]));
194215

216+
// Set path to Cmder user ConEmu config file
195217
PathCombine(userCfgPath, userConfigDirPath, L"user-ConEmu.xml");
196-
if (PathFileExists(cpuCfgPath)) {
197-
if (PathFileExists(cfgPath)) {
218+
219+
if (PathFileExists(cpuCfgPath)) // If machine-specific ConEmu config file exists - use it.
220+
{
221+
if (PathFileExists(cfgPath)) // If vendor ConEmu config file exists - back it up to config/ConEmu-%COMPUTERNAME%.xml.
222+
{
198223
if (!CopyFile(cfgPath, cpuCfgPath, FALSE))
199224
{
200225
MessageBox(NULL,
@@ -204,7 +229,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
204229
exit(1);
205230
}
206231
}
207-
else
232+
else // If vendor ConEmu config file does not exists - Copy machine-specific config/ConEmu-%COMPUTERNAME%.xml to vendor ConEmu.xml file
208233
{
209234
if (!CopyFile(cpuCfgPath, cfgPath, FALSE))
210235
{
@@ -216,8 +241,10 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
216241
}
217242
}
218243
}
219-
else if (PathFileExists(userCfgPath)) {
220-
if (PathFileExists(cfgPath)) {
244+
else if (PathFileExists(userCfgPath)) // If config/user_conemu.xml exists use it.
245+
{
246+
if (PathFileExists(cfgPath)) // If vendor conemu.xml exits back it up to config/user_conemu.xml.
247+
{
221248
if (!CopyFile(cfgPath, userCfgPath, FALSE))
222249
{
223250
MessageBox(NULL,
@@ -227,7 +254,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
227254
exit(1);
228255
}
229256
}
230-
else
257+
else // If vendor conemu.xml does not exist copy user_conemu.xml to vendor conemu.xml
231258
{
232259
if (!CopyFile(userCfgPath, cfgPath, FALSE))
233260
{
@@ -239,7 +266,8 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
239266
}
240267
}
241268
}
242-
else if (PathFileExists(cfgPath)) {
269+
else if (PathFileExists(cfgPath)) // If vendor conemu.xml exists copy config/user_conemu.xml
270+
{
243271
if (!CopyFile(cfgPath, userCfgPath, FALSE))
244272
{
245273
MessageBox(NULL,
@@ -249,7 +277,8 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
249277
exit(1);
250278
}
251279
}
252-
else {
280+
else // No previous conemu.xml config exists use the default.
281+
{
253282
if (!CopyFile(defaultCfgPath, cfgPath, FALSE))
254283
{
255284
MessageBox(NULL,
@@ -262,28 +291,34 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
262291

263292
SYSTEM_INFO sysInfo;
264293
GetNativeSystemInfo(&sysInfo);
265-
if (sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {
294+
if (sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
295+
{
266296
PathCombine(conEmuPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu64.exe");
267297
}
268-
else {
298+
else
299+
{
269300
PathCombine(conEmuPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.exe");
270301
}
271302

272303
if (is_single_mode)
273304
{
274-
if (!streqi(cmderTask.c_str(), L"")) {
305+
if (!streqi(cmderTask.c_str(), L""))
306+
{
275307
swprintf_s(args, L"%s /single /Icon \"%s\" /Title Cmder /dir \"%s\" /run {%s}", args, icoPath, cmderStart.c_str(), cmderTask.c_str());
276308
}
277-
else {
309+
else
310+
{
278311
swprintf_s(args, L"%s /single /Icon \"%s\" /Title Cmder /dir \"%s\"", args, icoPath, cmderStart.c_str());
279312
}
280313
}
281314
else
282315
{
283-
if (!streqi(cmderTask.c_str(), L"")) {
316+
if (!streqi(cmderTask.c_str(), L""))
317+
{
284318
swprintf_s(args, L"/Icon \"%s\" /Title Cmder /dir \"%s\" /run {%s}", icoPath, cmderStart.c_str(), cmderTask.c_str());
285319
}
286-
else {
320+
else
321+
{
287322
swprintf_s(args, L"%s /Icon \"%s\" /Title Cmder /dir \"%s\"", args, icoPath, cmderStart.c_str());
288323
}
289324
}
@@ -435,7 +470,8 @@ cmderOptions GetOption()
435470

436471
cmderOptions.cmderCfgRoot = cmderCfgRoot;
437472

438-
if (szArgList[i + 1] != NULL && szArgList[i + 1][0] != '/') {
473+
if (szArgList[i + 1] != NULL && szArgList[i + 1][0] != '/')
474+
{
439475
cmderOptions.cmderCfgRoot = szArgList[i + 1];
440476
i++;
441477
}
@@ -453,7 +489,8 @@ cmderOptions GetOption()
453489
cmderOptions.cmderStart = szArgList[i + 1];
454490
i++;
455491
}
456-
else {
492+
else
493+
{
457494
MessageBox(NULL, szArgList[i + 1], L"/START - Folder does not exist!", MB_OK);
458495
}
459496
}
@@ -505,11 +542,13 @@ cmderOptions GetOption()
505542
cmderOptions.cmderStart = szArgList[i];
506543
i++;
507544
}
508-
else {
545+
else
546+
{
509547
MessageBox(NULL, szArgList[i], L"Folder does not exist!", MB_OK);
510548
}
511549
}
512-
else {
550+
else
551+
{
513552
MessageBox(NULL, L"Unrecognized parameter.\n\nValid options:\n\n /c [CMDER User Root Path]\n\n /task [ConEmu Task Name]\n\n [/start [Start in Path] | [Start in Path]]\n\n /single\n\nor\n\n /register [USER | ALL]\n\nor\n\n /unregister [USER | ALL]\n", MB_TITLE, MB_OK);
514553
cmderOptions.error = true;
515554
}
@@ -531,7 +570,8 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
531570

532571
cmderOptions cmderOptions = GetOption();
533572

534-
if (cmderOptions.registerApp == true) {
573+
if (cmderOptions.registerApp == true)
574+
{
535575
RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_BACKGROUND);
536576
RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_LISTITEM);
537577
}
File renamed without changes.

0 commit comments

Comments
 (0)