fix bash and powershell init scripts

This commit is contained in:
Dax T. Games 2018-04-03 13:20:49 -04:00
parent bcf8527f74
commit 65bf25f1d0
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 if [ ! "x${profile_d_scripts}" = "x" ] ; then
for x in ${profile_d_scripts} ; do for x in ${profile_d_scripts} ; do
echo Sourcing "${1}/${x}"... # echo Sourcing "${1}/${x}"...
. "${1}/${x}" . "${1}/${x}"
done done
fi fi
@ -63,21 +63,21 @@ if [ -d "${CMDER_USER_CONFIG}/profile.d" ] ; then
runProfiled "${CMDER_USER_CONFIG}/profile.d" runProfiled "${CMDER_USER_CONFIG}/profile.d"
fi fi
initialConfig="${CMDER_ROOT}/config/user-profile.sh"
if [ -f "${CMDER_ROOT}/config/user-profile.sh" ] ; then if [ -f "${CMDER_ROOT}/config/user-profile.sh" ] ; then
. "${CMDER_ROOT}/config/user-profile.sh" . "${CMDER_ROOT}/config/user-profile.sh"
fi 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" . "${CMDER_USER_CONFIG}/user-profile.sh"
else fi
if [ "${CMDER_USER_CONFIG}" != "" ] ; then fi
initialProfile="${CMDER_USER_CONFIG}/user-profile.sh"
else
initialProfile="${CMDER_ROOT}/config/user-profile.sh"
fi
echo Creating user startup file: "${initialProfile}" if [ ! -f "${initialConfig}" ] ; then
cat <<-eof >"${initialProfile}" echo Creating user startup file: "${initialConfig}"
cat <<-eof >"${initialCodfig}"
# use this file to run your own startup commands for msys2 bash' # use this file to run your own startup commands for msys2 bash'
# To add a new vendor to the path, do something like: # 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 :var_loop
if "%~1" == "" ( if "%~1" == "" (
goto :start goto :start
) else if "%1"=="/v" ( ) else if /i "%1"=="/v" (
set verbose-output=1 set verbose-output=1
) else if "%1"=="/d" ( ) else if /i "%1"=="/d" (
set debug-output=1 set debug-output=1
) else if "%1" == "/max_depth" ( ) else if /i "%1" == "/max_depth" (
if "%~2" geq "1" if "%~2" leq "5" ( if "%~2" geq "1" if "%~2" leq "5" (
set "max_depth=%~2" set "max_depth=%~2"
shift 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!" %lib_console% show_error "'/max_depth' requires a number between 1 and 5!"
exit /b exit /b
) )
) else if "%1" == "/c" ( ) else if /i "%1" == "/c" (
if exist "%~2" ( if exist "%~2" (
if not exist "%~2\bin" mkdir "%~2\bin" if not exist "%~2\bin" mkdir "%~2\bin"
set "cmder_user_bin=%~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" set "cmder_user_config=%~2\config"
shift shift
) )
) else if "%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 "%1" == "/git_install_root" ( ) else if /i "%1" == "/git_install_root" (
if exist "%~2" ( if exist "%~2" (
set "GIT_INSTALL_ROOT=%~2" set "GIT_INSTALL_ROOT=%~2"
shift 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!" %lib_console% show_error "The Git install root folder "%~2", you specified does not exist!"
exit /b exit /b
) )
) else if "%1" == "/home" ( ) else if /i "%1" == "/home" (
if exist "%~2" ( if exist "%~2" (
set "HOME=%~2" set "HOME=%~2"
shift 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! %lib_console% show_error The home folder "%2", you specified does not exist!
exit /b exit /b
) )
) else if "%1" == "/svn_ssh" ( ) else if /i "%1" == "/svn_ssh" (
set SVN_SSH=%2 set SVN_SSH=%2
shift shift
) )
@ -182,7 +182,7 @@ for /F "delims=" %%F in ('where git.exe 2^>nul') do (
:VENDORED_GIT :VENDORED_GIT
if exist "%CMDER_ROOT%\vendor\git-for-windows" ( if exist "%CMDER_ROOT%\vendor\git-for-windows" (
set "GIT_INSTALL_ROOT=%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 ( ) else (
goto :NO_GIT 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%" %lib_console% debug-output init.bat "Env Var - GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%"
:: Enhance Path :: 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 ( if defined CMDER_USER_BIN (
%lib_path% enhance_path_recursive "%CMDER_USER_BIN%" %max_depth% %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%" if not defined HOME set "HOME=%USERPROFILE%"
%lib_console% debug-output init.bat "Env Var - HOME=%HOME%" %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" ( 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
call "%CMDER_ROOT%\config\user-profile.cmd" call "%CMDER_ROOT%\config\user-profile.cmd"
) )
if defined CMDER_USER_CONFIG if exist "%CMDER_USER_CONFIG%\user-profile.cmd" ( if defined CMDER_USER_CONFIG (
REM Create this file and place your own command in there set "initialConfig=%CMDER_USER_CONFIG%\user-profile.cmd"
call "%CMDER_USER_CONFIG%\user-profile.cmd" if exist "%CMDER_USER_CONFIG%\user-profile.cmd" (
) else ( REM Create this file and place your own command in there
echo Creating user startup file: "%CMDER_ROOT%\config\user-profile.cmd" 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 this file to run your own startup commands
echo :: use in front of the command to prevent printing the command echo :: use in front of the command to prevent printing the command
echo. 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 :: set "PATH=%%CMDER_ROOT%%\vendor\whatever;%%PATH%%"
echo. echo.
echo @echo off echo @echo off
) >"%temp%\user-profile.tmp" ) >"%initialConfig%"
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"
)
) )
set initialConfig=
exit /b 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" # 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 # 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 pushd $ENV:CMDER_USER_CONFIG\profile.d
foreach ($x in Get-ChildItem *.ps1) { foreach ($x in Get-ChildItem *.ps1) {
# write-host write-host Sourcing $x # write-host write-host Sourcing $x