为加快cmder启动,我们可以做一些简单优化,减少环境变量检测和批处理调用操作
优化前启动时间:1.69秒
优化后启动时间:0.53秒
1. 将cmder下批处理中lib_console输出禁用
具体操作为将批处理文件中%lib_console%替换为REM by Moxun - %lib_console%
2. 在vendor\init.bat第一行@echo off后添加以下内容
set GIT_INSTALL_ROOT=git所在路径
set LANG=zh_CN.UTF-8 不清楚的,执行 git所在路径\usr\binlocale -uU 2
3. 在:start处,注掉%lib_base% cmder_shell,并设置CMDER_SHELL, CMDER_CLINK, CMDER_ALIASES三变量值,CMDER_SHELL试自己选择而定,具体内容如下:
REM %lib_base% cmder_shell
set CMDER_SHELL=cmd
set CMDER_CLINK=1
set CMDER_ALIASES=1
4. 在:CONFIGURE_GIT处,使用set path替代%lib_path%调
REM if exist "!GIT_INSTALL_ROOT!\cmd\git.exe" %lib_path% enhance_path "!GIT_INSTALL_ROOT!\cmd" !path_position!
set PATH=!PATH!;!GIT_INSTALL_ROOT!\cmd;
if exist "!GIT_INSTALL_ROOT!\mingw32" (
REM %lib_path% enhance_path "!GIT_INSTALL_ROOT!\mingw32\bin" !path_position!
set PATH=!PATH!;!GIT_INSTALL_ROOT!\mingw32\bin
) else if exist "!GIT_INSTALL_ROOT!\mingw64" (
REM %lib_path% enhance_path "!GIT_INSTALL_ROOT!\mingw64\bin" !path_position!
set PATH=!PATH!;!GIT_INSTALL_ROOT!\mingw64\bin
)
if %nix_tools% geq 1 (
REM %lib_path% enhance_path "!GIT_INSTALL_ROOT!\usr\bin" !path_position!
set PATH=!PATH!;!GIT_INSTALL_ROOT!\usr\bin
)
5. 在:PATH_ENHANCE处,使用set path替代%lib_path%调用
REM %lib_path% enhance_path "%CMDER_ROOT%\vendor\bin"
set PATH=%PATH%;%CMDER_ROOT%\vendor\bin
REM %lib_path% enhance_path "%CMDER_ROOT%" append
set PATH=%PATH%;%CMDER_ROOT%
6. 在:PATH_ENHANCE处,选择性处理
注掉对%CMDER_ROOT%\bin下可执行文件的环境变量添加
REM %lib_path% enhance_path_recursive "%CMDER_ROOT%\bin" %max_depth%
若%CMDER_ROOT%\bin下放置了可执行文件,直接在init.bat以set path进行添加