Since I have lots of aliases and functions in my profile, frequently I need to search them by some pattern.
This Powershell
function lets me do just that.
function ff { param( [string]$Pattern ) # Define the path to the PowerShell profile $profilePath = $PROFILE # Check if the profile exists if (-not (Test-Path $profilePath)) { Write-Host "Profile script does not exist at $profilePath" return } # Define the patterns to search for aliases and functions $patterns = "Set-Alias.*$Pattern", "New-Alias.*$Pattern", "function.*$Pattern" # Search the profile for the specified pattern # Select-String -Path $profilePath -Pattern $patterns Select-String -Path $profilePath $patterns }
Now, all I need to do is type this to find the matching line and the actual function in my profile.
> ff <pattern>