mirror of
https://github.com/cmderdev/cmder.git
synced 2025-04-20 00:22:31 +08:00
fix multiuser user_init.cmd creation
This commit is contained in:
parent
615ba5f816
commit
4bf659833c
15
vendor/bin/create-cmdercfg.ps1
vendored
15
vendor/bin/create-cmdercfg.ps1
vendored
@ -2,18 +2,23 @@
|
|||||||
param(
|
param(
|
||||||
[Parameter()]
|
[Parameter()]
|
||||||
[string]$shell = 'cmd',
|
[string]$shell = 'cmd',
|
||||||
[string]$outfile = "$env:cmder_root\config\user_init.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
|
||||||
|
}
|
||||||
|
|
||||||
$CmderModulePath = Join-path $env:cmder_root "vendor/psmodules/"
|
$CmderModulePath = Join-path $env:cmder_root "vendor/psmodules/"
|
||||||
$CmderFunctions = Join-Path $CmderModulePath "Cmder.ps1"
|
$CmderFunctions = Join-Path $CmderModulePath "Cmder.ps1"
|
||||||
|
|
||||||
. $CmderFunctions
|
. $CmderFunctions
|
||||||
|
|
||||||
if ($shell -match 'cmd') {
|
if ($shell -match 'cmd') {
|
||||||
write-host "Generating Cmder Config for '$shell' shell in '$outfile'..."
|
write-host "Generating Cmder Config for '$shell' shell in '$outfile'..."
|
||||||
templateExpand "$env:cmder_root\vendor\user_init.cmd.template" "$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!"
|
|
||||||
}
|
}
|
||||||
|
19
vendor/init.bat
vendored
19
vendor/init.bat
vendored
@ -168,10 +168,11 @@ if "%PROCESSOR_ARCHITECTURE%"=="x86" (
|
|||||||
if defined CMDER_USER_CONFIG (
|
if defined CMDER_USER_CONFIG (
|
||||||
if exist "%CMDER_ROOT%\config\user_init.cmd" (
|
if exist "%CMDER_ROOT%\config\user_init.cmd" (
|
||||||
call "%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" (
|
) else if exist "%CMDER_USER_CONFIG%\config\user_init.cmd" (
|
||||||
call "%CMDER_USER_CONFIG%\config\user_init.cmd"
|
call "%CMDER_USER_CONFIG%\config\user_init.cmd"
|
||||||
|
exit /b
|
||||||
)
|
)
|
||||||
exit /b
|
|
||||||
) else if exist "%CMDER_ROOT%\config\user_init.cmd" (
|
) else if exist "%CMDER_ROOT%\config\user_init.cmd" (
|
||||||
call "%CMDER_ROOT%\config\user_init.cmd"
|
call "%CMDER_ROOT%\config\user_init.cmd"
|
||||||
exit /b
|
exit /b
|
||||||
@ -538,20 +539,8 @@ if "%CMDER_ALIASES%" == "1" if exist "%CMDER_ROOT%\bin\alias.bat" if exist "%CMD
|
|||||||
|
|
||||||
set initialConfig=
|
set initialConfig=
|
||||||
|
|
||||||
if defined CMDER_USER_CONFIG (
|
if not exist "%CMDER_CONFIG_DIR%\user_init.cmd" (
|
||||||
if not exist "%CMDER_ROOT%\config\user_init.cmd" if not exist "%CMDER_USER_ROOT%\config\user_init.cmd" (
|
powershell -f "%cmder_root%\vendor\bin\create-cmdercfg.ps1" -shell cmd -outfile "%CMDER_CONFIG_DIR%\user_init.cmd"
|
||||||
powershell -f %cmder_root%\vendor\bin\create-cmdercfg.ps1 -shell cmd -outfile "%CMDER_ROOT%\config\user_init.cmd"
|
|
||||||
)
|
|
||||||
|
|
||||||
if not exist "%CMDER_ROOT%\config\user_init.cmd" if not exist "%CMDER_USER_ROOT%\config\user_init.cmd" (
|
|
||||||
powershell -f %cmder_root%\vendor\bin\create-cmdercfg.ps1 -shell cmd -outfile "%CMDER_iUSER_ROOT%\config\user_init.cmd"
|
|
||||||
)
|
|
||||||
|
|
||||||
if not exist "%CMDER_ROOT%\config\user_init.cmd" if not exist "%CMDER_USER_ROOT%\config\user_init.cmd" (
|
|
||||||
%print_error% "Failed to generate Cmder config"
|
|
||||||
)
|
|
||||||
) else if not exist "%CMDER_ROOT%\config\user_init.cmd" (
|
|
||||||
powershell -f %cmder_root%\vendor\bin\create-cmdercfg.ps1 -shell cmd -outfile "%CMDER_ROOT%\config\user_init.cmd"
|
|
||||||
|
|
||||||
if not exist "%CMDER_ROOT%\config\user_init.cmd" (
|
if not exist "%CMDER_ROOT%\config\user_init.cmd" (
|
||||||
%print_error% "Failed to generate Cmder config"
|
%print_error% "Failed to generate Cmder config"
|
||||||
|
5
vendor/psmodules/Cmder.ps1
vendored
5
vendor/psmodules/Cmder.ps1
vendored
@ -186,8 +186,9 @@ function yOrn( $question ) {
|
|||||||
return $Answer
|
return $Answer
|
||||||
}
|
}
|
||||||
|
|
||||||
function templateExpand($template, $outfile) {
|
function templateExpand($template_filename, $outfile) {
|
||||||
$template = Get-Content $template -Raw
|
$template = Get-Content "$template_filename" -Raw
|
||||||
|
|
||||||
$expanded = Invoke-Expression "@`"`r`n$template`r`n`"@"
|
$expanded = Invoke-Expression "@`"`r`n$template`r`n`"@"
|
||||||
|
|
||||||
$overwrite = 'y'
|
$overwrite = 'y'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user