Skip to content

Commit a5bdecc

Browse files
daxgamesStanzilla
authored andcommitted
Add /f for fast init. (#1942)
The below enables Cmder Fast Init mode for `cmd.exe` sessions. This is more like the Cmder 1.3.5 init process. See issue #1821 Cmder Fast Init mode bypasses or disables the following Cmder 1.3.6+ features: * Git root and version detection. Defaults to `%cmder_root%\vendor\git-for-windows` if it exists. * Path enhance validation before path modify so `%Path%` enhancements are forced. * Recursive path add for `"%CMDER_ROOT%\bin"` * Recursive path add for `"%CMDER_USER_BIN%\bin"` if `/c [user_config_folder` is specified. * `/d` switch to enable debug output. * `/v` switch to enable debug output. Add `/f` to Cmder task as shown below t enable fast init: _Note 1: This setting is invalid in Cmder `Powershell` and `Bash` sessions~_ _Note 2: Add `/t` also to see init timer output_ ![image](https://user-images.githubusercontent.com/7318053/47957637-052e3880-df90-11e8-93ef-91e1ab696d82.png) Cuts ~2.4 seconds off of init time. ![image](https://user-images.githubusercontent.com/7318053/47957795-45db8100-df93-11e8-8ae0-551d12c4e2dc.png)
1 parent 5be25f2 commit a5bdecc

File tree

6 files changed

+38
-18
lines changed

6 files changed

+38
-18
lines changed

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,18 @@ You may find some Monokai color schemes for mintty to match Cmder [here](https:/
138138
139139
##### Command Line Arguments for `init.bat`
140140
141-
| Argument | Description | Default |
142-
| ----------------------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------- |
143-
| `/c [user cmder root]` | Enables user bin and config folders for 'Cmder as admin' sessions due to non-shared environment. | not set |
144-
| `/d` | Enables debug output. | not set |
145-
| `/git_install_root [file path]` | User specified Git installation root path. | `%CMDER_ROOT%\vendor\Git-for-Windows` |
146-
| `/home [home folder]` | User specified folder path to set `%HOME%` environment variable. | `%userprofile%` |
147-
| `/max_depth [1-5]` | Define max recurse depth when adding to the path for `%cmder_root%\bin` and `%cmder_user_bin%` | 1 |
148-
| `/svn_ssh [path to ssh.exe]` | Define `%SVN_SSH%` so we can use git svn with ssh svn repositories. | `%GIT_INSTALL_ROOT%\bin\ssh.exe` |
149-
| `/user_aliases [file path]` | File path pointing to user aliases. | `%CMDER_ROOT%\config\user-aliases.cmd` |
150-
| `/v` | Enables verbose output. | not set |
151-
| (custom arguments) | User defined arguments processed by `cexec`. Type `cexec /?` for more useage. | not set |
141+
| Argument | Description | Default |
142+
| ----------------------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------- |
143+
| `/c [user cmder root]` | Enables user bin and config folders for 'Cmder as admin' sessions due to non-shared environment. | not set |
144+
| `/d` | Enables debug output. | not set |
145+
| `/f` | Enables Cmder Fast Init Mode. This disables some features, see pull request [#1492](https://github.com/cmderdev/cmder/pull/1942) for more details. | not set |
146+
| `/git_install_root [file path]` | User specified Git installation root path. | `%CMDER_ROOT%\vendor\Git-for-Windows` |
147+
| `/home [home folder]` | User specified folder path to set `%HOME%` environment variable. | `%userprofile%` |
148+
| `/max_depth [1-5]` | Define max recurse depth when adding to the path for `%cmder_root%\bin` and `%cmder_user_bin%` | 1 |
149+
| `/svn_ssh [path to ssh.exe]` | Define `%SVN_SSH%` so we can use git svn with ssh svn repositories. | `%GIT_INSTALL_ROOT%\bin\ssh.exe` |
150+
| `/user_aliases [file path]` | File path pointing to user aliases. | `%CMDER_ROOT%\config\user-aliases.cmd` |
151+
| `/v` | Enables verbose output. | not set |
152+
| (custom arguments) | User defined arguments processed by `cexec`. Type `cexec /?` for more useage. | not set |
152153
153154
### Cmder Shell User Config
154155
Single user portable configuration is possible using the cmder specific shell config files. Edit the below files to add your own configuration:

vendor/init.bat

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ set cmder_init_start=%time%
1212
set verbose_output=0
1313
set debug_output=0
1414
set time_init=0
15+
set fast_init=0
1516
set max_depth=1
1617
set "CMDER_USER_FLAGS= "
1718

@@ -41,7 +42,9 @@ call "%cmder_root%\vendor\lib\lib_profile"
4142
:var_loop
4243
if "%~1" == "" (
4344
goto :start
44-
) else if /i "%1"=="/t" (
45+
) else if /i "%1" == "/f" (
46+
set fast_init=1
47+
) else if /i "%1" == "/t" (
4548
set time_init=1
4649
) else if /i "%1"=="/v" (
4750
set verbose_output=1
@@ -147,6 +150,11 @@ if not defined TERM set TERM=cygwin
147150
setlocal enabledelayedexpansion
148151
if defined GIT_INSTALL_ROOT (
149152
if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" goto :SPECIFIED_GIT
153+
) else if "%fast_init%" == "1" (
154+
if exist "%CMDER_ROOT%\vendor\git-for-windows\cmd\git.exe" (
155+
%lib_console% debug_output "Skipping Git Auto-Detect!"
156+
goto :VENDORED_GIT
157+
)
150158
)
151159

152160
%lib_console% debug_output init.bat "Looking for Git install root..."
@@ -208,7 +216,6 @@ for /F "delims=" %%F in ('where git.exe 2^>nul') do (
208216
if exist "%CMDER_ROOT%\vendor\git-for-windows" (
209217
set "GIT_INSTALL_ROOT=%CMDER_ROOT%\vendor\git-for-windows"
210218
%lib_console% debug_output "Using vendored Git from '!GIT_INSTALL_ROOT!..."
211-
%lib_path% enhance_path "!GIT_INSTALL_ROOT!\cmd"
212219
goto :CONFIGURE_GIT
213220
) else (
214221
goto :NO_GIT

vendor/lib/lib_console.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@echo off
22

3-
rem set args=%*
3+
if "%fast_init%" == "1" exit /b
44

55
call "%~dp0lib_base.cmd"
66
set lib_console=call "%~dp0lib_console.cmd"

vendor/lib/lib_git.cmd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
@echo off
22

3-
43
call "%~dp0lib_base.cmd"
54
call "%%~dp0lib_console.cmd"
65
set lib_git=call "%~dp0lib_git.cmd"
76

8-
97
if "%~1" == "/h" (
108
%lib_base% help "%~0"
119
) else if "%1" neq "" (

vendor/lib/lib_path.cmd

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ exit /b
5252
set "position="
5353
)
5454

55+
if "%fast_init%" == "1" (
56+
if "%position%" == "append" (
57+
set "PATH=%PATH%;%add_path%"
58+
) else (
59+
set "PATH=%add_path%;%PATH%"
60+
)
61+
goto :end_enhance_path
62+
)
63+
5564
set found=0
5665
set "find_query=%add_path%"
5766
set "find_query=%find_query:\=\\%"
@@ -85,6 +94,7 @@ exit /b
8594
%lib_console% debug_output :enhance_path "AFTER Env Var - PATH=!path!"
8695
)
8796

97+
:end_enhance_path
8898
endlocal & set "PATH=%PATH:;;=;%"
8999
exit /b
90100

@@ -115,7 +125,6 @@ exit /b
115125
:::.
116126
::: path <out> Sets the path env variable if required.
117127
:::-------------------------------------------------------------------------------
118-
119128
setlocal enabledelayedexpansion
120129
if "%~1" neq "" (
121130
set "add_path=%~1"
@@ -136,6 +145,11 @@ exit /b
136145
set "position="
137146
)
138147

148+
if "%fast_init%" == "1" (
149+
call :enhance_path "%add_path%" %position%
150+
goto :end_enhance_path_recursive
151+
)
152+
139153
if "%depth%" == "" set depth=0
140154

141155
%lib_console% debug_output :enhance_path_recursive "Env Var - add_path=%add_path%"
@@ -155,5 +169,6 @@ exit /b
155169
)
156170
)
157171

172+
:end_enhance_path_recursive
158173
endlocal & set "PATH=%PATH%"
159174
exit /b

vendor/lib/lib_profile.cmd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@echo off
22

3-
43
call "%~dp0lib_base.cmd"
54
call "%%~dp0lib_console"
65
set lib_profile=call "%~dp0lib_profile.cmd"

0 commit comments

Comments
 (0)