mirror of
https://github.com/cmderdev/cmder.git
synced 2025-07-31 20:39:21 +08:00
auto generate cmd user_init.cmd
This commit is contained in:
25
vendor/psmodules/Cmder.ps1
vendored
25
vendor/psmodules/Cmder.ps1
vendored
@ -176,3 +176,28 @@ function getGitStatusSetting() {
|
||||
|
||||
return $true
|
||||
}
|
||||
|
||||
function yOrn( $question ) {
|
||||
Do {
|
||||
$Answer = Read-Host -Prompt "`n${question}? (y/n) "
|
||||
}
|
||||
Until ($Answer -eq 'y' -or $Answer -eq 'n' -or $Answer -eq 'yes' -or $Answer -eq 'no')
|
||||
|
||||
return $Answer
|
||||
}
|
||||
|
||||
function templateExpand($template, $outfile) {
|
||||
$template = Get-Content $template -Raw
|
||||
$expanded = Invoke-Expression "@`"`r`n$template`r`n`"@"
|
||||
|
||||
$overwrite = 'y'
|
||||
if ((test-path "$outfile")) {
|
||||
$overwrite = yOrn "'$outfile' already exists do you want to overwrite it"
|
||||
}
|
||||
|
||||
if ($overwrite -match 'y') {
|
||||
$expanded | out-file -ErrorAction silentlycontinue -encoding ascii "$outfile"
|
||||
} else {
|
||||
write-host "Skipping Cmder '$shell' config generation at user request!"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user