auto generate cmd user_init.cmd

This commit is contained in:
Dax T. Games
2023-02-12 09:48:27 -08:00
parent 02154a8f88
commit 1e623ecab4
4 changed files with 233 additions and 1 deletions

View File

@ -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!"
}
}