Reload-MyAliases is now Reload-MyScripts

🔖 https://blog.lksz.me/editing-with-ease/

✏️ Fixed $MyPSScriptRoot typo
 Get-ScopeDepth
🐛 Get-MyAliases didn't work correctly when sub-scoped, fixed the issue
🚚 Reload-MyAliases is now Reload-MyScripts
🐛 Reload-MyScripts loads scripts from $MyPSScriptRoot/profile.d subdir
📝 README updated to reflect change of script name and typo
This commit is contained in:
lksz 2020-09-18 15:41:58 -04:00
parent bb2488e591
commit 06052cfa29
14 changed files with 186 additions and 13 deletions

View file

@ -12,7 +12,7 @@ The scripts all [assume](https://blog.lksz.me/functions-or-scripts/#myprofilecod
The code establishes the following variables:
* `$PathEnvDelimiter` - Linux/Unix it's `:`, while in Windows it's `;`
* `$MyPSModulePath` - Location to place personal Modules
* `$MyPSScrtipRoot` - Location of personal Scripts.
* `$MyPSScriptRoot` - Location of personal Scripts.
The code also makes sure `$MyPSScriptRoot` is in the `$env:PATH` environment vairable, and finally it calls [`Reload-MyAliases`](https://blog.lksz.me/a-case-of-sensitivity/#myaliases) if it exists.
@ -34,13 +34,13 @@ if( -not $MyPSModulePath ) {
}
$local:p = Split-PathEnv $env:PATH
$global:MyPSScrtipRoot = Join-Path (Split-Path -Parent $MyPSModulePath) Scripts
if( -not (Test-Path $MyPSScrtipRoot) ) {
New-Item -ItemType Directory -Path $MyPSScrtipRoot -Force | Out-Null
$global:MyPSScriptRoot = Join-Path (Split-Path -Parent $MyPSModulePath) Scripts
if( -not (Test-Path $MyPSScriptRoot) ) {
New-Item -ItemType Directory -Path $MyPSScriptRoot -Force | Out-Null
}
$p = @($p[0], $MyPSScrtipRoot) + $($p | Select-Object -Skip 1)
$p = @($p[0], $MyPSScriptRoot) + $($p | Select-Object -Skip 1)
$env:PATH = $p -join $PathEnvDelimiter
Get-Command Reload-MyAliases -ErrorAction SilentlyContinue | ForEach-Object { Reload-MyAliases }
Get-Command Reload-MyScripts -ErrorAction SilentlyContinue | ForEach-Object { . $_.Name }
```