Merge pull request #1739 from daxgames/fix_init

fix bash and powershell init scripts
This commit is contained in:
Benjamin Staneck 2018-04-05 23:48:26 +02:00 committed by GitHub
commit e746101ed2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 33 deletions

20
vendor/cmder.sh vendored
View File

@ -14,7 +14,7 @@ function runProfiled {
if [ ! "x${profile_d_scripts}" = "x" ] ; then
for x in ${profile_d_scripts} ; do
echo Sourcing "${1}/${x}"...
# echo Sourcing "${1}/${x}"...
. "${1}/${x}"
done
fi
@ -63,21 +63,21 @@ if [ -d "${CMDER_USER_CONFIG}/profile.d" ] ; then
runProfiled "${CMDER_USER_CONFIG}/profile.d"
fi
initialConfig="${CMDER_ROOT}/config/user-profile.sh"
if [ -f "${CMDER_ROOT}/config/user-profile.sh" ] ; then
. "${CMDER_ROOT}/config/user-profile.sh"
fi
if [ -f "${CMDER_USER_CONFIG}/user-profile.sh" ] ; then
if [ "${CMDER_USER_CONFIG}" != "" ] ; then
initialConfig="${CMDER_USER_CONFIG}/user-profile.sh"
if [ -f "${CMDER_USER_CONFIG}/user-profile.sh" ] ; then
. "${CMDER_USER_CONFIG}/user-profile.sh"
else
if [ "${CMDER_USER_CONFIG}" != "" ] ; then
initialProfile="${CMDER_USER_CONFIG}/user-profile.sh"
else
initialProfile="${CMDER_ROOT}/config/user-profile.sh"
fi
fi
fi
echo Creating user startup file: "${initialProfile}"
cat <<-eof >"${initialProfile}"
if [ ! -f "${initialConfig}" ] ; then
echo Creating user startup file: "${initialConfig}"
cat <<-eof >"${initialCodfig}"
# use this file to run your own startup commands for msys2 bash'
# To add a new vendor to the path, do something like:

45
vendor/init.bat vendored
View File

@ -36,11 +36,11 @@ call "%cmder_root%\vendor\lib\lib_profile"
:var_loop
if "%~1" == "" (
goto :start
) else if "%1"=="/v" (
) else if /i "%1"=="/v" (
set verbose-output=1
) else if "%1"=="/d" (
) else if /i "%1"=="/d" (
set debug-output=1
) else if "%1" == "/max_depth" (
) else if /i "%1" == "/max_depth" (
if "%~2" geq "1" if "%~2" leq "5" (
set "max_depth=%~2"
shift
@ -48,7 +48,7 @@ call "%cmder_root%\vendor\lib\lib_profile"
%lib_console% show_error "'/max_depth' requires a number between 1 and 5!"
exit /b
)
) else if "%1" == "/c" (
) else if /i "%1" == "/c" (
if exist "%~2" (
if not exist "%~2\bin" mkdir "%~2\bin"
set "cmder_user_bin=%~2\bin"
@ -56,12 +56,12 @@ call "%cmder_root%\vendor\lib\lib_profile"
set "cmder_user_config=%~2\config"
shift
)
) else if "%1" == "/user_aliases" (
) else if /i "%1" == "/user_aliases" (
if exist "%~2" (
set "user-aliases=%~2"
shift
)
) else if "%1" == "/git_install_root" (
) else if /i "%1" == "/git_install_root" (
if exist "%~2" (
set "GIT_INSTALL_ROOT=%~2"
shift
@ -69,7 +69,7 @@ call "%cmder_root%\vendor\lib\lib_profile"
%lib_console% show_error "The Git install root folder "%~2", you specified does not exist!"
exit /b
)
) else if "%1" == "/home" (
) else if /i "%1" == "/home" (
if exist "%~2" (
set "HOME=%~2"
shift
@ -77,7 +77,7 @@ call "%cmder_root%\vendor\lib\lib_profile"
%lib_console% show_error The home folder "%2", you specified does not exist!
exit /b
)
) else if "%1" == "/svn_ssh" (
) else if /i "%1" == "/svn_ssh" (
set SVN_SSH=%2
shift
)
@ -182,7 +182,7 @@ for /F "delims=" %%F in ('where git.exe 2^>nul') do (
:VENDORED_GIT
if exist "%CMDER_ROOT%\vendor\git-for-windows" (
set "GIT_INSTALL_ROOT=%CMDER_ROOT%\vendor\git-for-windows"
%lib_path% enhance_path "!GIT_INSTALL_ROOT!\cmd"
%lib_path% enhance_path "!GIT_INSTALL_ROOT!\cmd"
) else (
goto :NO_GIT
)
@ -208,7 +208,7 @@ endlocal & set "PATH=%PATH%" & set "SVN_SSH=%SVN_SSH%" & set "GIT_INSTALL_ROOT=%
%lib_console% debug-output init.bat "Env Var - GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%"
:: Enhance Path
%lib_path% enhance_path_recursive "%CMDER_ROOT%\bin" %max_depth%
%lib_path% enhance_path_recursive "%CMDER_ROOT%\bin" %max_depth%
if defined CMDER_USER_BIN (
%lib_path% enhance_path_recursive "%CMDER_USER_BIN%" %max_depth%
)
@ -287,17 +287,23 @@ if exist "%GIT_INSTALL_ROOT%\post-install.bat" (
if not defined HOME set "HOME=%USERPROFILE%"
%lib_console% debug-output init.bat "Env Var - HOME=%HOME%"
set "initialConfig=%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
call "%CMDER_ROOT%\config\user-profile.cmd"
)
if defined CMDER_USER_CONFIG if exist "%CMDER_USER_CONFIG%\user-profile.cmd" (
REM Create this file and place your own command in there
call "%CMDER_USER_CONFIG%\user-profile.cmd"
) else (
echo Creating user startup file: "%CMDER_ROOT%\config\user-profile.cmd"
if defined CMDER_USER_CONFIG (
set "initialConfig=%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
call "%CMDER_USER_CONFIG%\user-profile.cmd"
)
)
if not exist "%initialConfig%" (
(
echo Creating user startup file: "%initialConfig%"
echo :: use this file to run your own startup commands
echo :: use in front of the command to prevent printing the command
echo.
@ -312,13 +318,8 @@ echo :: you can add your plugins to the cmder path like so
echo :: set "PATH=%%CMDER_ROOT%%\vendor\whatever;%%PATH%%"
echo.
echo @echo off
) >"%temp%\user-profile.tmp"
if defined CMDER_USER_CONFIG (
copy "%temp%\user-profile.tmp" "%CMDER_USER_CONFIG%\user-profile.cmd"
) else (
copy "%temp%\user-profile.tmp" "%CMDER_ROOT%\config\user-profile.cmd"
)
) >"%initialConfig%"
)
set initialConfig=
exit /b

2
vendor/profile.ps1 vendored
View File

@ -140,7 +140,7 @@ popd
# Drop *.ps1 files into "$ENV:CMDER_USER_CONFIG\config\profile.d"
# to source them at startup. Requires using cmder.exe /C [cmder_user_root_path] argument
if ($ENV:CMDER_USER_CONFIG -ne "" -and -not (test-path "$ENV:CMDER_USER_CONFIG\profile.d")) {
if ($ENV:CMDER_USER_CONFIG -ne "" -and (test-path "$ENV:CMDER_USER_CONFIG\profile.d")) {
pushd $ENV:CMDER_USER_CONFIG\profile.d
foreach ($x in Get-ChildItem *.ps1) {
# write-host write-host Sourcing $x