Fix Cmder not changing to CMDER_START (#1399)

* Fix Cmder not changing to CMDER_START

Fix to allow Cmder to change to different startup directory if already on the same drive as CMDER_START
possibly relevant: HOME != USERPROFILE

* make "Cmder Here" work in more cases

integrated suggestion from comments (test for trailing backslash to prevent doubling of trailing backslash)
integrated suggestions from #1456: switching ```cd /d``` over to ```pushd``` to get support for UNC-paths

* replaced 'cd /d' with 'pushd'

replaced two more instances of 'cd /d' with 'pushd' to support network paths.
Also added double quotes to the use of '%USERPROFILE%' to prevent issues with spaces.
I also noticed that 'pushd', in contrast to 'cd /d' does not require the trailing backslash for drive roots (on Win7). Therefore I removed the trailing backslash check.

* Don't assume / is needed at end

* Update init.bat
This commit is contained in:
Hugo-KTM 2017-08-27 19:46:47 +02:00 committed by Benjamin Staneck
parent e9a78a30d1
commit 22d27afed5

11
vendor/init.bat vendored
View File

@ -149,9 +149,9 @@ call "%user-aliases%"
:: manually extracting the archive rather than executing the 7z sfx
if exist "%CMDER_ROOT%\vendor\git-for-windows\post-install.bat" (
call :verbose-output Running Git for Windows one time Post Install....
cd /d "%CMDER_ROOT%\vendor\git-for-windows\"
pushd "%CMDER_ROOT%\vendor\git-for-windows\"
"%CMDER_ROOT%\vendor\git-for-windows\git-bash.exe" --no-needs-console --hide --no-cd --command=post-install.bat
cd /d %USERPROFILE%
pushd "%USERPROFILE%"
)
:: Set home path
@ -159,10 +159,15 @@ if not defined HOME set "HOME=%USERPROFILE%"
:: This is either a env variable set by the user or the result of
:: cmder.exe setting this variable due to a commandline argument or a "cmder here"
setlocal enabledelayedexpansion
if defined CMDER_START (
cd /d "%CMDER_START%"
if "%CMDER_START:~-1%" neq "\" (
SET "CMDER_START=%CMDER_START%\"
)
pushd "!CMDER_START!"
)
endlocal
if exist "%CMDER_ROOT%\config\user-profile.cmd" (
REM Create this file and place your own command in there