Skip to content

backmind/PSAliasFinder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PSAliasFinder

PowerShell Gallery License: MIT

Intelligent alias discovery for PowerShell, inspired by the oh-my-zsh alias-finder plugin.

PSAliasFinder helps you discover and use shorter aliases for PowerShell commands, improving your terminal productivity. It automatically suggests aliases when you type long commands and provides tools to search for available aliases.

Features

  • πŸ” Intelligent Alias Search - Find aliases for any PowerShell command
  • 🎯 Smart Filtering - Only suggests aliases that save significant typing
  • ⚑ Automatic Suggestions - Get alias recommendations as you type
  • 🎨 PSReadLine Integration - Seamless integration with PowerShell prompt
  • πŸ”§ Flexible Configuration - Enable/disable automatic suggestions easily
  • πŸ“Š Multiple Search Modes - Exact, longer, cheaper search options

Installation

From PowerShell Gallery (Recommended)

Install-Module -Name PSAliasFinder -Scope CurrentUser

Manual Installation

  1. Download the latest release from GitHub
  2. Extract to your PowerShell modules directory:
    • Windows: $env:USERPROFILE\Documents\PowerShell\Modules\PSAliasFinder
    • Linux/macOS: ~/.local/share/powershell/Modules/PSAliasFinder

Quick Start

Import the Module

Import-Module PSAliasFinder

Search for Aliases Manually

# Find aliases for a command
Find-Alias Get-ChildItem
# Output: gci -> Get-ChildItem
#         ls -> Get-ChildItem
#         dir -> Get-ChildItem

# Using the short alias
af Get-Process
# Output: gps -> Get-Process
#         ps -> Get-Process

Enable Automatic Suggestions

# Enable automatic alias detection
Set-AliasFinderHook -Enable

# Now when you type long commands, you'll get suggestions:
# PS> Get-ChildItem
#
# Found existing alias for "Get-ChildItem". You should use: "gci", "ls", "dir"

Add to Your Profile

Add this to your PowerShell profile ($PROFILE) to enable automatically:

Import-Module PSAliasFinder
Set-AliasFinderHook -Enable

Or configure with options:

Import-Module PSAliasFinder
$global:PSAliasFinderConfig = @{ AutoLoad = $true }

Usage Examples

Basic Search

# Find aliases for Get-ChildItem
Find-Alias Get-ChildItem

# Using the 'af' shorthand
af Get-Process

# Search with exact match only
af Get-ChildItem -Exact

# Include longer aliases (contains the command)
af Process -Longer

Advanced Options

# Only show aliases shorter than the command
af Get-ChildItem -Cheaper

# Bypass intelligent filtering (show all matches)
af ls -Force

# Suppress output, only return results
$aliases = af Get-Process -Quiet

Hook Management

# Enable automatic suggestions
Set-AliasFinderHook -Enable

# Disable automatic suggestions
Set-AliasFinderHook -Disable

# Configure with AutoLoad
Set-AliasFinderConfig -AutoLoad

How It Works

PSAliasFinder uses intelligent filtering to avoid noise:

  • βœ… Command length check - Only suggests for commands β‰₯8 characters
  • βœ… Complexity check - Skips commands with multiple pipes or many arguments
  • βœ… Savings check - Only suggests aliases that save β‰₯4 characters
  • βœ… AST parsing - Accurately counts pipes using PowerShell's Abstract Syntax Tree

This ensures you only see helpful suggestions, not clutter.

Commands Reference

Find-Alias

Search for aliases matching a command.

Syntax:

Find-Alias [-Command] <String[]> [-Exact] [-Longer] [-Cheaper] [-Quiet] [-Force]

Parameters:

  • -Command - The command to search (required)
  • -Exact - Find only exact matches
  • -Longer - Include aliases longer than the command
  • -Cheaper - Only show aliases shorter than the command
  • -Quiet - Suppress console output
  • -Force - Bypass intelligent filtering

Aliases: af, alias-finder

Set-AliasFinderHook

Enable or disable automatic alias suggestions.

Syntax:

Set-AliasFinderHook [-Enable] [-Disable]

Parameters:

  • -Enable - Activate automatic suggestions
  • -Disable - Deactivate automatic suggestions

Set-AliasFinderConfig

Configure module behavior.

Syntax:

Set-AliasFinderConfig [-AutoLoad]

Parameters:

  • -AutoLoad - Enable automatic suggestions on module import

Requirements

  • PowerShell 5.1 or higher
  • PSReadLine module (for automatic suggestions feature)

Comparison with oh-my-zsh alias-finder

Feature oh-my-zsh PSAliasFinder
Find aliases βœ… βœ…
Exact/Longer/Cheaper modes βœ… βœ…
Automatic suggestions βœ… βœ…
Intelligent filtering ❌ βœ…
AST-based pipe counting ❌ βœ…
Complexity validation ❌ βœ…
Quiet mode ❌ βœ…
Force mode (show all) ❌ βœ…

PSAliasFinder extends the original concept with PowerShell-specific enhancements and smarter filtering.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Support


Made with ❀️ for PowerShell users

About

PowerShell Alias Discovery Module Based on the oh-my-zsh alias-finder plugin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published