PowerShell_Scripts/Edit-MyProfiles.ps1
lksz ae07e06c27 Setup-Profile and co.
Setup-Profile included, read all about it at
https://blog.lksz.me/the-profile-and-setting-it-up
When running Edit-MyScript without parameters, the $MyPSScriptRoot path
will be sent (editing the directory)
Added ability to edit scripts with Edit-MyPrfiles, making editing
profiles alongside scripts easy.
2020-09-25 01:30:21 -04:00

23 satır
655 B
PowerShell

[CmdletBinding(SupportsShouldProcess)]param(
[switch]$sudo,
[switch]$Force,
[Parameter(ValueFromRemainingArguments = $true)]
[ArgumentCompleter({ param (
$commandName,
$parameterName,
$wordToComplete,
$commandAst,
$fakeBoundParameters
)
[MyScript]::_GetValidValues($wordToComplete,$false)
})]
[string[]]$AlsoEditTheseScripts
)
$local:FilePaths = @() + $( Get-Profiles | Where-Object { $_.Exists -or $Force } | Select-Object -ExpandProperty Path )
foreach( $local:p in $AlsoEditTheseScripts ) {
$local:sp = Join-Path $MyPSScriptRoot "$p`.ps1"
$FilePaths += $sp
}
Edit-TextFile -sudo:$sudo $FilePaths