Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizations for improving speed #2825

Open
wants to merge 62 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
274cce1
optimize for speed
daxgames Feb 11, 2023
56f45a8
add debugging of path adds
daxgames Feb 12, 2023
7e50f50
add vendor/user_init.optional.cmd
daxgames Feb 12, 2023
727a99b
shared or user user_init.cmd
daxgames Feb 12, 2023
02154a8
Update to only collext cmder env vars
daxgames Feb 12, 2023
1e623ec
auto generate cmd user_init.cmd
daxgames Feb 12, 2023
3a2e747
add cleanup of unused env vars
daxgames Feb 18, 2023
9cbc184
cleanup
daxgames Feb 18, 2023
615ba5f
Delete user_init.optional.cmd
daxgames Feb 18, 2023
f1e2fb5
prevent timer results every time.
daxgames Feb 27, 2023
e0b6943
add bypass
daxgames Mar 5, 2023
c4d9365
x
daxgames Mar 11, 2023
f08ad62
Merge branch 'master' of https://github.com/cmderdev/cmder into more_…
daxgames Mar 11, 2023
42568b7
Document '--' command line argument
daxgames Mar 12, 2023
6180aa5
Merge branch 'master' into development
DRSDavidSoft Apr 23, 2023
3f53d1b
Merge branch 'master' into development
DRSDavidSoft Apr 24, 2023
b46f726
Merge branch 'master' into more_speed_2
May 8, 2023
50c3ea4
Merge branch 'master' into development
DRSDavidSoft May 11, 2023
c1f8dfd
Merge branch 'master' into development
DRSDavidSoft May 16, 2023
5a90558
Merge branch 'master' into development
DRSDavidSoft May 17, 2023
9a851da
Merge remote-tracking branch 'upstream/master' into more_speed_2
May 18, 2023
37c41e8
Merge branch 'master' into development
DRSDavidSoft May 23, 2023
b2135cd
don't error if vim slias exists
May 30, 2023
dac3090
Merge remote-tracking branch 'origin/more_speed_2' into more_speed_2
May 30, 2023
7b55dab
Merge remote-tracking branch 'upstream/master' into more_speed_2
May 30, 2023
86b9fb2
Add ability to launch git bash from external Installed git whwen usin…
Jun 5, 2023
ea0a9bb
Merge branch 'master' into more_speed_2
Jun 5, 2023
4bf6598
fix multiuser user_init.cmd creation
daxgames Jul 3, 2023
294f85e
fixes
daxgames Jul 3, 2023
3ca0379
sync
daxgames Jul 3, 2023
cd92c9f
cleanup
daxgames Jul 3, 2023
15addb8
Merge branch 'master' into development
DRSDavidSoft Jul 4, 2023
5311b25
Merge remote-tracking branch 'upstream/master' into more_speed_2
daxgames Jul 4, 2023
3ced7a2
'.gitignore
daxgames Jul 4, 2023
4129084
add comment to clink.lua explaining /c [folderpath]
daxgames Jul 8, 2023
f517494
Merge branch 'master' into development
MartiUK Jul 20, 2023
5d4c45d
Merge branch 'master' into development
MartiUK Jul 24, 2023
ff7621c
Merge branch 'master' into development
MartiUK Jul 24, 2023
4104a56
Merge branch 'master' into development
MartiUK Jul 24, 2023
b47cf43
Merge pull request #14 from cmderdev/master
daxgames Jul 25, 2023
a01fb4c
Merge branch 'master' into development
DRSDavidSoft Jul 25, 2023
41f0454
Merge branch 'master' into development
DRSDavidSoft Jul 25, 2023
1adaab9
Merge branch 'master' into development
MartiUK Jul 27, 2023
9a13594
Merge branch 'master' into development
DRSDavidSoft Jul 27, 2023
9b446b3
Merge remote-tracking branch 'upstream/master' into more_speed_2
daxgames Jul 28, 2023
52e1a02
Merge remote-tracking branch 'upstream/master' into more_speed_2
daxgames Aug 11, 2023
bd857ba
Merge remote-tracking branch 'origin/more_speed_2' into more_speed_2
daxgames Aug 11, 2023
6b330b8
allow launching windows terminal w/cmder from cmder
daxgames Aug 11, 2023
e52fa81
Merge branch 'more_speed_2' of https://github.com/daxgames/cmder into…
daxgames Aug 11, 2023
d3497f5
Merge branch 'master' into development
DRSDavidSoft Sep 21, 2023
94ea2da
make it work with windows terminal
daxgames Sep 22, 2023
7c04ee9
fixes
daxgames Sep 22, 2023
3b8e87d
Merge branch 'master' of https://github.com/cmderdev/cmder
daxgames Sep 25, 2023
9ee2bef
Merge branch 'master' into development
daxgames Sep 25, 2023
092dc4d
Merge branch 'master' into development
daxgames Oct 14, 2023
0874f4b
Merge branch 'master' into development
DRSDavidSoft Oct 25, 2023
5e22496
Merge branch 'master' into development
daxgames Nov 5, 2023
90d86a7
add vendor/bin/create-cmdercfg.cmd
daxgames Nov 6, 2023
289bcf0
Merge remote-tracking branch 'upstream/development'
daxgames Nov 11, 2023
219c879
Merge remote-tracking branch 'upstream/master'
daxgames Nov 11, 2023
01c41a9
Merge branch 'master' into more_speed_2
daxgames Nov 11, 2023
6e21311
Merge branch 'more_speed_2' of https://github.com/daxgames/cmder into…
daxgames Nov 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,10 @@ launcher/src/version.rc2
.vs/*
.vscode
.idea
.vagrant/
scripts/packer/iso/*.iso
!scripts/packer/floppy/*.exe
scripts/packer/packer_cache
scripts/packer/output-*
*.box

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ The Cmder's user interface is also designed to be more eye pleasing, and you can
| `/SINGLE` | Start Cmder in single mode. |
| `/START [start_path]` | Folder path to start in. |
| `/TASK [task_name]` | Task to start after launch. |
| `/X [ConEmu extras pars]` | Forwards parameters to ConEmu |
| `-- [ConEmu extras pars]` | Forwards ALL remaining parameters to ConEmu. |

## Context Menu Integration

Expand Down
2 changes: 1 addition & 1 deletion launcher/src/strings.rc2
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ STRINGTABLE
{
IDS_TITLE "Cmder Launcher"

IDS_SWITCHES L"Valid options:\n\n /c [CMDER User Root Path]\n /task [ConEmu Task Name]\n /icon [CMDER Icon Path]\n [/start [Start in Path] | [Start in Path]]\n /single\n /m\n /x [ConEmu extra arguments]\n\nor, either:\n /register [USER | ALL]\n /unregister [USER | ALL]"
IDS_SWITCHES L"Valid options:\n\n /c [CMDER User Root Path]\n /task [ConEmu Task Name]\n /icon [CMDER Icon Path]\n [/start [Start in Path] | [Start in Path]]\n /single\n /m\n -- [ConEmu extra arguments]\n\nNote: '-- [...]' must be the last argument!\n\nor, either:\n /register [USER | ALL]\n /unregister [USER | ALL]"
}

/////////////////////////////////////////////////////////////////////////////
131 changes: 81 additions & 50 deletions vendor/ConEmu.xml.default

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions vendor/bin/cmder_diag.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

(echo.
echo ------------------------------------
echo set
echo Get Cmder env variables...
echo ------------------------------------
set
set | findstr -i -r "^aliases= architecture_bits ccall= cexec= ^clink_ ^cmder ^debug_output= fast_init= ^GIT_INSTALL_ROOT= ^git_locale= ^HOME= ^max_depth= ^nix_tools= ^path_position= ^path= ^PLINK_PROTOCOL= ^print_ ^SVN_SSH= ^time_init= ^user_aliases= ^verbose_output="

echo.
echo ------------------------------------
Expand Down
30 changes: 30 additions & 0 deletions vendor/bin/create-cmdercfg.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[CmdletBinding()]
param(
[Parameter()]
[string]$shell = 'cmd',
[string]$outfile = "$env:cmder_config_dir\user_init.cmd"
)

if ($shell -match 'powershell') {
write-host "'$shell' is not supported at this time!"
exit 0
} elseif ($shell -match 'bash') {
write-host "'$shell' is not supported at this time!"
exit 0
} elseif ($shell -notMatch 'cmd') {
exit 0
}

$CmderModulePath = Join-path $env:cmder_root "vendor/psmodules/"
$CmderFunctions = Join-Path $CmderModulePath "Cmder.ps1"

. $CmderFunctions

if ($shell -match 'cmd') {
write-host "Generating Cmder Config for '$shell' shell in '$outfile'..."
templateExpand "$env:cmder_root\vendor\user_init.cmd.template" "$outfile"
} elseif ($shell -match 'powershell') {
write-host "'$shell' is not supported at this time!"
} elseif ($shell -match 'bash') {
write-host "'$shell' is not supported at this time!"
}
24 changes: 24 additions & 0 deletions vendor/bin/timer.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ set /a hours=%end_h%-%start_h%
set /a mins=%end_m%-%start_m%
set /a secs=%end_s%-%start_s%
set /a ms=%end_ms%-%start_ms%

if %ms% lss 0 set /a secs = %secs% - 1 & set /a ms = 100%ms%
if %secs% lss 0 set /a mins = %mins% - 1 & set /a secs = 60%secs%
if %mins% lss 0 set /a hours = %hours% - 1 & set /a mins = 60%mins%
Expand All @@ -20,3 +21,26 @@ if 1%ms% lss 100 set ms=0%ms%
:: Mission accomplished
set /a totalsecs = %hours%*3600 + %mins%*60 + %secs%
echo Elapsed Time: %hours%:%mins%:%secs%.%ms% (%totalsecs%.%ms%s total)

:: cleanup
set start=
set end=
set options=

set start_h=
set start_m=
set start_s=
set start_ms=

set end_h=
set end_m=
set end_s=
set end_ms=

set hours=
set mins=
set secs=
set ms=

set totalsecs=

4 changes: 4 additions & 0 deletions vendor/clink.lua
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,10 @@ for _,lua_module in ipairs(clink.find_files(completions_dir..'*.lua')) do
end
end

-- If Cmder is launched with '/c [folderPath]', indicating Cmder is installed globally and
-- each user has a private '[folderPath]\config' folder, Clink won't know about the global
-- '%cmder_root%\config dir, so we need to load scripts from there before . Clink loads lua
-- scripts from the profile directory given to it when it was injected.
if clink.get_env('CMDER_USER_CONFIG') then
local cmder_config_dir = clink.get_env('CMDER_ROOT')..'/config/'
for _,lua_module in ipairs(clink.find_files(cmder_config_dir..'*.lua')) do
Expand Down
15 changes: 5 additions & 10 deletions vendor/cmder_exinit
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ function runProfiled {
unset profile_d_scripts
pushd "${1}" >/dev/null

if [ ! "x${ZSH_VERSION}" = "x" ]; then
if [ -n "${ZSH_VERSION}" ]; then
profile_d_scripts=$(ls *.zsh 2>/dev/null)
elif [ ! "x${BASH_VERSION}" = "x" ]; then
elif [ -n "${BASH_VERSION}" ]; then
profile_d_scripts=$(ls *.sh 2>/dev/null)
fi

if [ ! "x${profile_d_scripts}" = "x" ] ; then
if [ -n "${profile_d_scripts}" ] ; then
for x in ${profile_d_scripts} ; do
echo Sourcing "${1}/${x}"...
. "${1}/${x}"
done
fi
Expand All @@ -46,21 +45,17 @@ function runProfiled {

# We do this for bash as admin sessions since $CMDER_ROOT is not being set
if [ "$CMDER_ROOT" = "" -a "$ConEmuDir" != "" ] ; then
if [ -d "${ConEmuDir}../../vendor" ] ; then
if [ -d "${ConEmuDir}/../../vendor" ] ; then
case "$ConEmuDir" in *\\*) CMDER_ROOT=$( cd "$(cygpath -u "$ConEmuDir")/../.." ; pwd );; esac
else
echo "Running in ConEmu without Cmder, skipping Cmder integration."
fi
elif [ "$CMDER_ROOT" != "" ] ; then
case "$CMDER_ROOT" in *\\*) CMDER_ROOT="$(cygpath -u "$CMDER_ROOT")";; esac
fi

if [ ! "$CMDER_ROOT" = "" ] ; then
if [ -n "$CMDER_ROOT" ] ; then
# Remove any trailing '/'
CMDER_ROOT=$(echo $CMDER_ROOT | sed 's:/*$::')

echo "Using \"CMDER_ROOT\" at \"${CMDER_ROOT}\"."

export CMDER_ROOT

PATH=${CMDER_ROOT}/bin:${CMDER_ROOT}/vendor/bin:$PATH:${CMDER_ROOT}
Expand Down
15 changes: 13 additions & 2 deletions vendor/git-prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ then
. ~/.config/git/git-prompt.sh
fi
else
PS1='\[\033]0;$MSYSTEM:${PWD//[^[:ascii:]]/?}\007\]' # set window title
PS1='\[\033]0;$TITLEPREFIX:$PWD\007\]' # set window title
# PS1="$PS1"'\n' # new line
PS1="$PS1"'\[\033[32m\]' # change to green
PS1="$PS1"'\u@\h ' # user@host<space>
Expand Down Expand Up @@ -71,4 +71,15 @@ else
PS1="$PS1"'λ ' # prompt: always λ
fi

MSYS2_PS1="$PS1" # for detection by MSYS2 SDK's bash.basrc
MSYS2_PS1="$PS1" # for detection by MSYS2 SDK's bash.basrc

# Evaluate all user-specific Bash completion scripts (if any)
if test -z "$WINELOADERNOEXEC"
then
for c in "$HOME"/bash_completion.d/*.bash
do
# Handle absence of any scripts (or the folder) gracefully
test ! -f "$c" ||
. "$c"
done
fi
117 changes: 99 additions & 18 deletions vendor/init.bat
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,24 @@ if "%PROCESSOR_ARCHITECTURE%"=="x86" (
set CMDER_CLINK=0
)

if defined CMDER_USER_CONFIG (
if exist "%CMDER_ROOT%\config\user_init.cmd" (
call "%CMDER_ROOT%\config\user_init.cmd"
exit /b
) else if exist "%CMDER_USER_CONFIG%\config\user_init.cmd" (
call "%CMDER_USER_CONFIG%\config\user_init.cmd"
exit /b
)
) else if exist "%CMDER_ROOT%\config\user_init.cmd" (
call "%CMDER_ROOT%\config\user_init.cmd"
exit /b
)

if "%CMDER_CLINK%" == "1" (
REM TODO: Detect if clink is already injected, if so goto :CLINK_FINISH
goto :INJECT_CLINK
) else if "%CMDER_CLINK%" == "2" (
goto :CLINK_FINISH
)

goto :SKIP_CLINK
Expand Down Expand Up @@ -205,6 +220,7 @@ goto :SKIP_CLINK
)

"%CMDER_ROOT%\vendor\clink\clink_%clink_architecture%.exe" inject --quiet --profile "%CMDER_CONFIG_DIR%" --scripts "%CMDER_ROOT%\vendor"
set CMDER_CLINK=2

:: Check if a fatal error occurred when trying to inject Clink
if errorlevel 2 (
Expand Down Expand Up @@ -299,17 +315,22 @@ if exist "%CMDER_ROOT%\vendor\git-for-windows" (
)

:SPECIFIED_GIT
%print_debug% init.bat "Using /GIT_INSTALL_ROOT..."
%print_debug% init.bat "Using specified GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%...."
goto :CONFIGURE_GIT

:FOUND_GIT
%print_debug% init.bat "Using found Git '%GIT_VERSION_USER%' from '%GIT_INSTALL_ROOT%..."
%print_debug% init.bat "Using found Git '%GIT_VERSION_USER%' from 'v%GIT_INSTALL_ROOT%..."
goto :CONFIGURE_GIT

:CONFIGURE_GIT
%print_debug% init.bat "Using Git from '%GIT_INSTALL_ROOT%..."

:: Add git to the path
if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" %lib_path% enhance_path "%GIT_INSTALL_ROOT%\cmd" ""
%print_debug% init.bat "START - git.exe(prepend): Env Var - PATH=%path%"
if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" (
set "path=%GIT_INSTALL_ROOT%\cmd;%path%"
)
%print_debug% init.bat "END - git.exe(prepend): Env Var - PATH=%path%"

:: Add the unix commands at the end to not shadow windows commands like `more` and `find`
if %nix_tools% equ 1 (
Expand All @@ -320,16 +341,30 @@ if %nix_tools% equ 1 (
set "path_position="
)

%print_debug% init.bat "START - nix_tools(%path_position%): Env Var - PATH=%path%"
if %nix_tools% geq 1 (
if exist "%GIT_INSTALL_ROOT%\mingw32" (
%lib_path% enhance_path "%GIT_INSTALL_ROOT%\mingw32\bin" %path_position%
if "%path_position%" == "append" (
set "path=%path%;%GIT_INSTALL_ROOT%\mingw32\bin"
) else (
set "path=%GIT_INSTALL_ROOT%\mingw32\bin;%path%"
)
) else if exist "%GIT_INSTALL_ROOT%\mingw64" (
%lib_path% enhance_path "%GIT_INSTALL_ROOT%\mingw64\bin" %path_position%
if "%path_position%" == "append" (
set "path=%path%;%GIT_INSTALL_ROOT%\mingw64\bin"
) else (
set "path=%GIT_INSTALL_ROOT%\mingw64\bin;%path%"
)
)
if exist "%GIT_INSTALL_ROOT%\usr\bin" (
%lib_path% enhance_path "%GIT_INSTALL_ROOT%\usr\bin" %path_position%
if "%path_position%" == "append" (
set "path=%path%;%GIT_INSTALL_ROOT%\usr\bin"
) else (
set "path=%GIT_INSTALL_ROOT%\usr\bin;%path%"
)
)
)
%print_debug% init.bat "END - nix_tools(%path_position%): Env Var - PATH=%path%"

:SET_ENV

Expand Down Expand Up @@ -362,23 +397,41 @@ if defined git_locale (
)
endlocal && set LANG=%LANG%

%print_debug% init.bat "Env Var - GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%"
%print_debug% init.bat "Found Git in: '%GIT_INSTALL_ROOT%'"
%print_debug% init.bat "Found Git in: 'GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%'"
goto :PATH_ENHANCE

:NO_GIT
:: Skip this if GIT WAS FOUND else we did 'endlocal' above!
endlocal

:PATH_ENHANCE
%lib_path% enhance_path "%CMDER_ROOT%\vendor\bin"
%print_debug% init.bat "START - vendor/bin(prepend): Env Var - PATH=%path%"
set "path=%CMDER_ROOT%\vendor\bin;%path%"
%print_debug% init.bat "END - vendor/bin(prepend): Env Var - PATH=%path%"

:USER_CONFIG_START
%lib_path% enhance_path_recursive "%CMDER_ROOT%\bin" 0 %max_depth%
if defined CMDER_USER_BIN (
%print_debug% init.bat "START - bin(prepend): Env Var - PATH=%path%"
if %max_depth% gtr 1 (
%lib_path% enhance_path_recursive "%CMDER_ROOT%\bin" 0 %max_depth%
) else (
set "path=%CMDER_ROOT%\bin;%path%"
)
%print_debug% init.bat "END - bin(prepend): Env Var - PATH=%path%"


if defined CMDER_USER_BIN if defined CMDER_USER_ROOT (
%print_debug% init.bat "START - user_bin(prepend): Env Var - PATH=%path%"
if %max_depth% gtr 1 (
%lib_path% enhance_path_recursive "%CMDER_USER_BIN%" 0 %max_depth%
) else (
set "path=%CMDER_USER_ROOT%\bin;%path%"
)
%print_debug% init.bat "END - user_bin(prepend): Env Var - PATH=!path!"
)
%lib_path% enhance_path "%CMDER_ROOT%" append

%print_debug% init.bat "START - cmder_root(append): Env Var - PATH=%path%"
set "path=%path%;%CMDER_ROOT%"
%print_debug% init.bat "END - cmder_root(append): Env Var - PATH=%path%"

:: Drop *.bat and *.cmd files into "%CMDER_ROOT%\config\profile.d"
:: to run them at startup.
Expand Down Expand Up @@ -487,12 +540,40 @@ if "%CMDER_ALIASES%" == "1" if exist "%CMDER_ROOT%\bin\alias.bat" if exist "%CMD

set initialConfig=

:CMDER_CONFIGURED
if not defined CMDER_CONFIGURED set CMDER_CONFIGURED=1

set CMDER_INIT_END=%time%
if not exist "%CMDER_CONFIG_DIR%\user_init.cmd" (
powershell -f "%cmder_root%\vendor\bin\create-cmdercfg.ps1" -shell cmd -outfile "%CMDER_CONFIG_DIR%\user_init.cmd"

if %time_init% gtr 0 (
"%cmder_root%\vendor\bin\timer.cmd" "%CMDER_INIT_START%" "%CMDER_INIT_END%"
if not exist "%CMDER_ROOT%\config\user_init.cmd" (
%print_error% "Failed to generate Cmder config"
)
)

:CMDER_CONFIGURED
if not defined CMDER_CONFIGURED set CMDER_CONFIGURED=1
set CMDER_INIT_END=%time%

if "%time_init%" == "1" if "%CMDER_INIT_END%" neq "" if "%CMDER_INIT_START%" neq "" (
call "%cmder_root%\vendor\bin\timer.cmd" "%CMDER_INIT_START%" "%CMDER_INIT_END%"
)

:CLEANUP
set architecture_bits=
set CMDER_ALIASES=
set CMDER_INIT_END=
set CMDER_INIT_START=
set CMDER_USER_FLAGS=
set CMDER_CLINK=
set debug_output=
set fast_init=
set max_depth=
set nix_tools=
set path_position=
set print_debug=
set print_error=
set print_verbose=
set print_warning=
set time_init=
set verbose_output=
set user_aliases=

exit /b
Loading
Loading