Skip to content

Commit 84231d3

Browse files
Friedrich WeinmannFriedrich Weinmann
authored andcommitted
Implemented default alias override
1 parent 3a39f4a commit 84231d3

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Set-PSFConfig -Module PSUtil -Name 'Import.Aliases.Grep' -Value $true -Initialize -Validation "bool" -Handler { } -Description "Whether the module will on import create an alias named 'grep' for Select-String"
22
Set-PSFConfig -Module PSUtil -Name 'Import.Keybindings' -Value $true -Initialize -Validation "bool" -Handler { } -Description "Whether the module will on import register keybindings in PSReadline"
3+
Set-PSFConfig -Module PSUtil -Name 'Import.Alias.SystemOverride' -Value $false -Initialize -Validation "bool" -Description "Whether the module will on import pverwrite some default aliases with custom versions. Affects 'select' and 'gm'"
34

45
Set-PSFConfig -Module 'PSUtil' -Name 'Import.DoDotSource' -Value $false -Initialize -Validation 'bool' -Description "Whether the module files should be dotsourced on import. By default, the files of this module are read as string value and invoked, which is faster but worse on debugging."
56
Set-PSFConfig -Module 'PSUtil' -Name 'Import.IndividualFiles' -Value $false -Initialize -Validation 'bool' -Description "Whether the module files should be imported individually. During the module build, all module code is compiled into few files, which are imported instead by default. Loading the compiled versions is faster, using the individual files is easier for debugging and testing out adjustments."

PSUtil/internal/scripts/aliases.ps1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,12 @@ Import-PSUAlias -Name "new" -Command "New-Object"
2121

2222
# Add alias for the better select and to avoid breaking on old command
2323
Import-PSUAlias -Name "spo" -Command "Select-PSFObject"
24-
Import-PSUAlias -Name "Select-PSUObject" -Command "Select-PSFObject"
24+
Import-PSUAlias -Name "Select-PSUObject" -Command "Select-PSFObject"
25+
26+
if (Get-PSFConfigValue -FullName 'PSUtil.Import.Alias.SystemOverride')
27+
{
28+
Remove-PSFAlias -Name select -Force
29+
Remove-PSFAlias -Name gm -Force
30+
Import-PSUAlias -Name select -Command 'Select-PSFObject'
31+
Import-PSUAlias -Name gm -Command 'Get-PSMDMember'
32+
}

0 commit comments

Comments
 (0)