mirror of
https://github.com/cmderdev/cmder.git
synced 2025-01-10 16:29:08 +08:00
use user_conemu.xml or conemu-%computername%.xml directly if '-c [path]' is used to start cmder.
This commit is contained in:
parent
d04cc1f04e
commit
e904ebce72
@ -91,6 +91,8 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
|
|||||||
wchar_t userAliasesPath[MAX_PATH] = { 0 };
|
wchar_t userAliasesPath[MAX_PATH] = { 0 };
|
||||||
wchar_t legacyUserAliasesPath[MAX_PATH] = { 0 };
|
wchar_t legacyUserAliasesPath[MAX_PATH] = { 0 };
|
||||||
wchar_t args[MAX_PATH * 2 + 256] = { 0 };
|
wchar_t args[MAX_PATH * 2 + 256] = { 0 };
|
||||||
|
wchar_t userConEmuCfgPath[MAX_PATH] = { 0 };
|
||||||
|
|
||||||
|
|
||||||
std::wstring cmderStart = path;
|
std::wstring cmderStart = path;
|
||||||
std::wstring cmderTask = taskName;
|
std::wstring cmderTask = taskName;
|
||||||
@ -217,6 +219,8 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
|
|||||||
PathCombine(userCfgPath, userConfigDirPath, L"user-ConEmu.xml");
|
PathCombine(userCfgPath, userConfigDirPath, L"user-ConEmu.xml");
|
||||||
|
|
||||||
if (PathFileExists(cpuCfgPath)) // config/ConEmu-%COMPUTERNAME%.xml file exists, use it.
|
if (PathFileExists(cpuCfgPath)) // config/ConEmu-%COMPUTERNAME%.xml file exists, use it.
|
||||||
|
{
|
||||||
|
if (cfgRoot.length() == 0) // '-C [PATH]' was NOT specified
|
||||||
{
|
{
|
||||||
if (PathFileExists(cfgPath)) // vendor/conemu-maximus5/ConEmu.xml file exists, copy vendor/conemu-maximus5/ConEmu.xml to config/ConEmu-%COMPUTERNAME%.xml.
|
if (PathFileExists(cfgPath)) // vendor/conemu-maximus5/ConEmu.xml file exists, copy vendor/conemu-maximus5/ConEmu.xml to config/ConEmu-%COMPUTERNAME%.xml.
|
||||||
{
|
{
|
||||||
@ -241,7 +245,15 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else // '-C [PATH]' was specified, don't copy anything and use existing conemu-%COMPUTERNAME%.xml to start comemu.
|
||||||
|
{
|
||||||
|
PathCombine(userConEmuCfgPath, userConfigDirPath, L"ConEmu-%COMPUTERNAME%.xml");
|
||||||
|
ExpandEnvironmentStrings(userConEmuCfgPath, userConEmuCfgPath, sizeof(userConEmuCfgPath) / sizeof(userConEmuCfgPath[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (PathFileExists(userCfgPath)) // config/user_conemu.xml exists, use it.
|
else if (PathFileExists(userCfgPath)) // config/user_conemu.xml 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)) // vendor/conemu-maximus5/ConEmu.xml exists, copy vendor/conemu-maximus5/ConEmu.xml to config/user_conemu.xml.
|
||||||
{
|
{
|
||||||
@ -266,7 +278,14 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (PathFileExists(cfgPath)) // vendor/conemu-maximus5/ConEmu.xml exists, copy vendor/conemu-maximus5/ConEmu.xml to config/user_conemu.xml
|
else // '-C [PATH]' was specified, don't copy anything and use existing user_conemu.xml to start comemu.
|
||||||
|
{
|
||||||
|
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 (!CopyFile(cfgPath, userCfgPath, FALSE))
|
if (!CopyFile(cfgPath, userCfgPath, FALSE))
|
||||||
{
|
{
|
||||||
@ -276,12 +295,10 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
|
|||||||
: L"Failed to copy vendor/conemu-maximus5/ConEmu.xml file to config/user-conemu.xml!", MB_TITLE, MB_ICONSTOP);
|
: L"Failed to copy vendor/conemu-maximus5/ConEmu.xml file to config/user-conemu.xml!", MB_TITLE, MB_ICONSTOP);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else // vendor/ConEmu.xml config exists, copy Cmder vendor/ConEmu.xml file to vendor/conemu-maximus5/ConEmu.xml.
|
else // vendor/ConEmu.xml config exists, copy Cmder vendor/ConEmu.xml file to vendor/conemu-maximus5/ConEmu.xml.
|
||||||
{
|
{
|
||||||
if ( ! CopyFile(defaultCfgPath, cfgPath, FALSE))
|
if (!CopyFile(defaultCfgPath, cfgPath, FALSE))
|
||||||
{
|
{
|
||||||
ShowErrorAndExit(GetLastError(), __WFUNCTION__, __LINE__);
|
|
||||||
MessageBox(NULL,
|
MessageBox(NULL,
|
||||||
(GetLastError() == ERROR_ACCESS_DENIED)
|
(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! Access Denied."
|
||||||
@ -289,6 +306,20 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // '-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))
|
||||||
|
{
|
||||||
|
MessageBox(NULL,
|
||||||
|
(GetLastError() == ERROR_ACCESS_DENIED)
|
||||||
|
? L"Failed to copy vendor/ConEmu.xml.default file to [user specified path]/config/user_ConEmu.xml! Access Denied."
|
||||||
|
: L"Failed to copy vendor/ConEmu.xml.default file to [user specified path]/config/user_ConEmu.xml!", MB_TITLE, MB_ICONSTOP);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
PathCombine(userConEmuCfgPath, userConfigDirPath, L"user-ConEmu.xml");
|
||||||
|
}
|
||||||
|
|
||||||
SYSTEM_INFO sysInfo;
|
SYSTEM_INFO sysInfo;
|
||||||
GetNativeSystemInfo(&sysInfo);
|
GetNativeSystemInfo(&sysInfo);
|
||||||
@ -301,27 +332,26 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
|
|||||||
PathCombine(conEmuPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.exe");
|
PathCombine(conEmuPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.exe");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
swprintf_s(args, L"%s /Icon \"%s\" /Title Cmder", args, icoPath);
|
||||||
|
|
||||||
|
if (!streqi(cmderStart.c_str(), L""))
|
||||||
|
{
|
||||||
|
swprintf_s(args, L"%s /dir \"%s\"", args, cmderStart.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
if (is_single_mode)
|
if (is_single_mode)
|
||||||
{
|
{
|
||||||
|
swprintf_s(args, L"%s /single", args);
|
||||||
|
}
|
||||||
|
|
||||||
if (!streqi(cmderTask.c_str(), L""))
|
if (!streqi(cmderTask.c_str(), L""))
|
||||||
{
|
{
|
||||||
swprintf_s(args, L"%s /single /Icon \"%s\" /Title Cmder /dir \"%s\" /run {%s}", args, icoPath, cmderStart.c_str(), cmderTask.c_str());
|
swprintf_s(args, L"%s /run {%s}", args, cmderTask.c_str());
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (cfgRoot.length() != 0)
|
||||||
{
|
{
|
||||||
swprintf_s(args, L"%s /single /Icon \"%s\" /Title Cmder /dir \"%s\"", args, icoPath, cmderStart.c_str());
|
swprintf_s(args, L"%s -loadcfgfile \"%s\"", args, userConEmuCfgPath);
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!streqi(cmderTask.c_str(), L""))
|
|
||||||
{
|
|
||||||
swprintf_s(args, L"/Icon \"%s\" /Title Cmder /dir \"%s\" /run {%s}", icoPath, cmderStart.c_str(), cmderTask.c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
swprintf_s(args, L"%s /Icon \"%s\" /Title Cmder /dir \"%s\"", args, icoPath, cmderStart.c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
|
SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
|
||||||
|
2
vendor/init.bat
vendored
2
vendor/init.bat
vendored
@ -346,6 +346,7 @@ if not defined HOME set "HOME=%USERPROFILE%"
|
|||||||
set "initialConfig=%CMDER_ROOT%\config\user_profile.cmd"
|
set "initialConfig=%CMDER_ROOT%\config\user_profile.cmd"
|
||||||
if exist "%CMDER_ROOT%\config\user_profile.cmd" (
|
if exist "%CMDER_ROOT%\config\user_profile.cmd" (
|
||||||
REM Create this file and place your own command in there
|
REM Create this file and place your own command in there
|
||||||
|
%lib_console% debug_output init.bat "Calling - %CMDER_ROOT%\config\user_profile.cmd"
|
||||||
call "%CMDER_ROOT%\config\user_profile.cmd"
|
call "%CMDER_ROOT%\config\user_profile.cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -353,6 +354,7 @@ if defined CMDER_USER_CONFIG (
|
|||||||
set "initialConfig=%CMDER_USER_CONFIG%\user_profile.cmd"
|
set "initialConfig=%CMDER_USER_CONFIG%\user_profile.cmd"
|
||||||
if exist "%CMDER_USER_CONFIG%\user_profile.cmd" (
|
if exist "%CMDER_USER_CONFIG%\user_profile.cmd" (
|
||||||
REM Create this file and place your own command in there
|
REM Create this file and place your own command in there
|
||||||
|
%lib_console% debug_output init.bat "Calling - %CMDER_USER_CONFIG%\user_profile.cmd
|
||||||
call "%CMDER_USER_CONFIG%\user_profile.cmd"
|
call "%CMDER_USER_CONFIG%\user_profile.cmd"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user