move user-aliases.cmd to user_aliases.cmd

This commit is contained in:
Dax T. Games 2018-09-01 18:17:09 -04:00
parent 70788dc1e5
commit 451fb46ce1
2 changed files with 52 additions and 22 deletions

View File

@ -88,6 +88,8 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
wchar_t userProfiledDirPath[MAX_PATH] = { 0 }; wchar_t userProfiledDirPath[MAX_PATH] = { 0 };
wchar_t userProfilePath[MAX_PATH] = { 0 }; wchar_t userProfilePath[MAX_PATH] = { 0 };
wchar_t legacyUserProfilePath[MAX_PATH] = { 0 }; wchar_t legacyUserProfilePath[MAX_PATH] = { 0 };
wchar_t userAliasesPath[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 };
std::wstring cmderStart = path; std::wstring cmderStart = path;
@ -122,6 +124,20 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
rename(lPr, pR); rename(lPr, pR);
} }
PathCombine(legacyUserAliasesPath, configDirPath, L"user-aliases.cmd");
if (PathFileExists(legacyUserAliasesPath)) {
PathCombine(userAliasesPath, configDirPath, L"user_aliases.cmd");
char *lPr = (char *)malloc(MAX_PATH);
char *pR = (char *)malloc(MAX_PATH);
size_t i;
wcstombs_s(&i, lPr, (size_t)MAX_PATH,
legacyUserAliasesPath, (size_t)MAX_PATH);
wcstombs_s(&i, pR, (size_t)MAX_PATH,
userAliasesPath, (size_t)MAX_PATH);
rename(lPr, pR);
}
if (wcscmp(userConfigDirPath, L"") == 0) if (wcscmp(userConfigDirPath, L"") == 0)
{ {
PathCombine(userConfigDirPath, exeDir, L"config"); PathCombine(userConfigDirPath, exeDir, L"config");
@ -150,6 +166,20 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
userProfilePath, (size_t)MAX_PATH); userProfilePath, (size_t)MAX_PATH);
rename(lPr, pR); rename(lPr, pR);
} }
PathCombine(legacyUserAliasesPath, userConfigDirPath, L"user-aliases.cmd");
if (PathFileExists(legacyUserAliasesPath)) {
PathCombine(userAliasesPath, userConfigDirPath, L"user_aliases.cmd");
char *lPr = (char *)malloc(MAX_PATH);
char *pR = (char *)malloc(MAX_PATH);
size_t i;
wcstombs_s(&i, lPr, (size_t)MAX_PATH,
legacyUserAliasesPath, (size_t)MAX_PATH);
wcstombs_s(&i, pR, (size_t)MAX_PATH,
userAliasesPath, (size_t)MAX_PATH);
rename(lPr, pR);
}
} }
// Set path to vendored ConEmu config file // Set path to vendored ConEmu config file

44
vendor/init.bat vendored
View File

@ -58,7 +58,7 @@ call "%cmder_root%\vendor\lib\lib_profile"
) )
) else if /i "%1" == "/user_aliases" ( ) else if /i "%1" == "/user_aliases" (
if exist "%~2" ( if exist "%~2" (
set "user-aliases=%~2" set "user_aliases=%~2"
shift shift
) )
) else if /i "%1" == "/git_install_root" ( ) else if /i "%1" == "/git_install_root" (
@ -236,53 +236,53 @@ if defined CMDER_USER_CONFIG (
:: scripts run above by setting the 'aliases' env variable. :: scripts run above by setting the 'aliases' env variable.
:: ::
:: Note: If overriding default aliases store file the aliases :: Note: If overriding default aliases store file the aliases
:: must also be self executing, see '.\user-aliases.cmd.example', :: must also be self executing, see '.\user_aliases.cmd.example',
:: and be in profile.d folder. :: and be in profile.d folder.
if not defined user-aliases ( if not defined user_aliases (
if defined CMDER_USER_CONFIG ( if defined CMDER_USER_CONFIG (
set "user-aliases=%CMDER_USER_CONFIG%\user-aliases.cmd" set "user_aliases=%CMDER_USER_CONFIG%\user_aliases.cmd"
) else ( ) else (
set "user-aliases=%CMDER_ROOT%\config\user-aliases.cmd" set "user_aliases=%CMDER_ROOT%\config\user_aliases.cmd"
) )
) )
:: The aliases environment variable is used by alias.bat to id :: The aliases environment variable is used by alias.bat to id
:: the default file to store new aliases in. :: the default file to store new aliases in.
if not defined aliases ( if not defined aliases (
set "aliases=%user-aliases%" set "aliases=%user_aliases%"
) )
:: Make sure we have a self-extracting user-aliases.cmd file :: Make sure we have a self-extracting user_aliases.cmd file
setlocal enabledelayedexpansion setlocal enabledelayedexpansion
if not exist "%user-aliases%" ( if not exist "%user_aliases%" (
echo Creating initial user-aliases store in "%user-aliases%"... echo Creating initial user_aliases store in "%user_aliases%"...
copy "%CMDER_ROOT%\vendor\user-aliases.cmd.example" "%user-aliases%" copy "%CMDER_ROOT%\vendor\user_aliases.cmd.example" "%user_aliases%"
) else ( ) else (
type "%user-aliases%" | findstr /i ";= Add aliases below here" >nul type "%user_aliases%" | findstr /i ";= Add aliases below here" >nul
if "!errorlevel!" == "1" ( if "!errorlevel!" == "1" (
echo Creating initial user-aliases store in "%user-aliases%"... echo Creating initial user_aliases store in "%user_aliases%"...
if defined CMDER_USER_CONFIG ( if defined CMDER_USER_CONFIG (
copy "%user-aliases%" "%user-aliases%.old_format" copy "%user_aliases%" "%user_aliases%.old_format"
copy "%CMDER_ROOT%\vendor\user-aliases.cmd.example" "%user-aliases%" copy "%CMDER_ROOT%\vendor\user_aliases.cmd.example" "%user_aliases%"
) else ( ) else (
copy "%user-aliases%" "%user-aliases%.old_format" copy "%user_aliases%" "%user_aliases%.old_format"
copy "%CMDER_ROOT%\vendor\user-aliases.cmd.example" "%user-aliases%" copy "%CMDER_ROOT%\vendor\user_aliases.cmd.example" "%user_aliases%"
) )
) )
) )
:: Update old 'user-aliases' to new self executing 'user-aliases.cmd' :: Update old 'user_aliases' to new self executing 'user_aliases.cmd'
if exist "%CMDER_ROOT%\config\aliases" ( if exist "%CMDER_ROOT%\config\aliases" (
echo Updating old "%CMDER_ROOT%\config\aliases" to new format... echo Updating old "%CMDER_ROOT%\config\aliases" to new format...
type "%CMDER_ROOT%\config\aliases" >> "%user-aliases%" && del "%CMDER_ROOT%\config\aliases" type "%CMDER_ROOT%\config\aliases" >> "%user_aliases%" && del "%CMDER_ROOT%\config\aliases"
) else if exist "%user-aliases%.old_format" ( ) else if exist "%user_aliases%.old_format" (
echo Updating old "%user-aliases%" to new format... echo Updating old "%user_aliases%" to new format...
type "%user-aliases%.old_format" >> "%user-aliases%" && del "%user-aliases%.old_format" type "%user_aliases%.old_format" >> "%user_aliases%" && del "%user_aliases%.old_format"
) )
endlocal endlocal
:: Add aliases to the environment :: Add aliases to the environment
call "%user-aliases%" call "%user_aliases%"
:: See vendor\git-for-windows\README.portable for why we do this :: See vendor\git-for-windows\README.portable for why we do this
:: Basically we need to execute this post-install.bat because we are :: Basically we need to execute this post-install.bat because we are