Skip to content

Commit

Permalink
Merge pull request #1739 from daxgames/fix_init
Browse files Browse the repository at this point in the history
fix bash and powershell init scripts
  • Loading branch information
Stanzilla authored Apr 5, 2018
2 parents bcf8527 + 65bf25f commit e746101
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 34 deletions.
22 changes: 11 additions & 11 deletions vendor/cmder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

echo Creating user startup file: "${initialProfile}"
cat <<-eof >"${initialProfile}"
fi
fi

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:
Expand Down
45 changes: 23 additions & 22 deletions vendor/init.bat
Original file line number Diff line number Diff line change
Expand Up @@ -36,48 +36,48 @@ 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
) else (
%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"
if not exist "%~2\config\profile.d" mkdir "%~2\config\profile.d"
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
) else (
%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
) else (
%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
)
Expand Down Expand Up @@ -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
)
Expand All @@ -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%
)
Expand Down Expand Up @@ -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.
Expand All @@ -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 changes: 1 addition & 1 deletion vendor/profile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e746101

Please sign in to comment.