-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_aliases.ps1
More file actions
30 lines (23 loc) · 1.1 KB
/
_aliases.ps1
File metadata and controls
30 lines (23 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
param([switch]$VerboseSwitch = $false)
$Verbose = $VerboseSwitch
$script = $MyInvocation.MyCommand
if (-not $env:SnippetsInitialized) {
$fileInfo = New-Object System.IO.FileInfo (Get-Item $PSScriptRoot).FullName
$path = $fileInfo.Directory.FullName
$commonPath = Join-Path $path -ChildPath 'Snippets\_common.ps1'
if (-not (Test-Path $commonPath)) {
$commonPath = Join-Path $path -ChildPath '_common.ps1'
}
. $commonPath
Initialize-Snippets -Verbose:$Verbose
}
$moduleRoot = if ($env:Snippets) { $env:Snippets } else { $PSScriptRoot }
$modulePath = Join-Path $moduleRoot -ChildPath 'SnippetsAliasManager.psm1'
if (-not (Test-Path $modulePath)) {
throw [ErrorRecord]::new("Cannot locate ``SnippetsAliasManager.psm1`` in ``$env:Snippets``")
}
Import-Module $modulePath -Force -Verbose:$false
$result = Import-SnippetsAliases -VerboseSwitch:$Verbose
$alias = Set-Alias -Verbose:$Verbose -Scope Global -Description 'Snippets: [aliases] Manage Snippets aliases' -Name als -Value Invoke-AliasManager -PassThru
Write-Verbose "[$script] Set-Alias $alias" -Verbose:$Verbose
return $result