Script directory for a PowerShell profile. https://blog.lksz.me/keeping-track-of-everything/#-mypsscriptroot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
975 B

  1. [CmdletBinding(SupportsShouldProcess)]param()
  2. $local:myAliases = [ordered]@{}
  3. $myAliases.sudo = 'Invoke-MySudo'
  4. $myAliases.vi = 'Edit-TextFile'
  5. $myAliases.vim = 'Edit-TextFile'
  6. $myAliases.nvim = 'Edit-TextFile'
  7. $myAliases.nvim = 'Edit-TextFile'
  8. #######################################################################
  9. $local:IsVerbose = [bool]($PSBoundParameters['Verbose'])
  10. $local:MyAliasScope = 1
  11. $local:oldAliases = Get-MyAliases
  12. $oldAliases = Get-Alias -Scope $MyAliasScope |
  13. Where-Object Name -in $($oldAliases.Name + $myAliases.Keys)
  14. if( $oldAliases -and $IsVerbose ) {
  15. Write-Verbose "Removing: $($oldAliases.Name -join ', ')"
  16. }
  17. $oldAliases | Remove-Alias -Scope $MyAliasScope
  18. Get-ChildItem (Join-Path $MyPSScrtipRoot '*.ps1') |
  19. ForEach-Object {
  20. Set-Alias $($_.BaseName) $_.FullName -Scope $MyAliasScope
  21. }
  22. foreach( $local:alias in $myAliases.Keys ) {
  23. Set-Alias -Name $alias -Value $myAliases[$alias] -Description '#MyAlias' -Scope $MyAliasScope
  24. }