Go to file
lksz 06052cfa29 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
2020-09-18 15:56:40 -04:00
profile.d Reload-MyAliases is now Reload-MyScripts 2020-09-18 15:56:40 -04:00
.gitignore Reload-MyAliases is now Reload-MyScripts 2020-09-18 15:56:40 -04:00
Edit-MyProfiles.ps1 Reload-MyAliases is now Reload-MyScripts 2020-09-18 15:56:40 -04:00
Edit-MyScript.ps1 Reload-MyAliases is now Reload-MyScripts 2020-09-18 15:56:40 -04:00
Edit-TextFile.ps1 Reload-MyAliases is now Reload-MyScripts 2020-09-18 15:56:40 -04:00
Export-FunctionSource.ps1 Reload-MyAliases is now Reload-MyScripts 2020-09-18 15:56:40 -04:00
Get-MyAliases.ps1 Reload-MyAliases is now Reload-MyScripts 2020-09-18 15:56:40 -04:00
Get-MyScript.ps1 Reload-MyAliases is now Reload-MyScripts 2020-09-18 15:56:40 -04:00
Get-PossibleArguments.ps1 Reload-MyAliases is now Reload-MyScripts 2020-09-18 15:56:40 -04:00
Get-Profiles.ps1 Reload-MyAliases is now Reload-MyScripts 2020-09-18 15:56:40 -04:00
Get-ScopeDepth.ps1 Reload-MyAliases is now Reload-MyScripts 2020-09-18 15:56:40 -04:00
LICENSE Initial commit 2020-09-16 10:56:03 -04:00
README.md Reload-MyAliases is now Reload-MyScripts 2020-09-18 15:56:40 -04:00
Reload-MyScripts.ps1 Reload-MyAliases is now Reload-MyScripts 2020-09-18 15:56:40 -04:00

README.md

PowerShell Scripts

These are the scripts that go into $MyPSScriptRoot which is part of my $env:PATH.

The development of these is documented in my blog: https://blog.lksz.me

They are provided 'as is' for your review and for your reuse.

There is a blog post about how to clone this repo and use it as your own.

The scripts all assume the code below is part of one of your $PROFILE files. The code establishes the following variables:

  • $PathEnvDelimiter - Linux/Unix it's :, while in Windows it's ;
  • $MyPSModulePath - Location to place personal Modules
  • $MyPSScriptRoot - Location of personal Scripts.

The code also makes sure $MyPSScriptRoot is in the $env:PATH environment vairable, and finally it calls Reload-MyAliases if it exists.

$global:PathEnvDelimiter = $(if( $PSVersionTable.Platform -match 'unix' ) {':'} else {';'})
function Split-PathEnv {
param([string]$EnvPath)
  $EnvPath -split $PathEnvDelimiter
}

$global:MyPSModulePath = Split-PathEnv $env:PSModulePath | Where-Object { $_ -match "^$(Resolve-Path ~)" }

if( -not $MyPSModulePath ) {
  $MyPSModulePath = Resolve-Path ~/powershell/Modules
  if( -not (Test-Path $MyPSModulePath) ) {
      New-Item -ItemType Directory -Path $MyPSModulePath -Force | Out-Null
  }
  $env:PSModulePath = "$MyPSModulePath$PathEnvDelimiter$env:PSModulePath"
}

$local:p = Split-PathEnv $env:PATH
$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], $MyPSScriptRoot) + $($p | Select-Object -Skip 1)
$env:PATH = $p -join $PathEnvDelimiter

Get-Command Reload-MyScripts -ErrorAction SilentlyContinue | ForEach-Object { . $_.Name }