Skip to content

About

A PowerShell module for managing YAML-backed shortcut aliases for apps, scripts, and URLs.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

pwsh_shortcut_alias

Read this in other languages: English, 中文.

pwsh_shortcut_alias is a PowerShell module for managing shortcut aliases backed by a YAML file. It lets you register short commands for local programs, .lnk shortcuts, scripts, and URLs, then launch them from any PowerShell session after a refresh.

Project Repository: pwsh_shortcut_alias PowerShell Gallery: pwsh_shortcut_alias

Why Use It

  • Create shortcut aliases for frequently used programs or scripts
  • Support alias add, remove, fuzzy search, and refresh operations
  • Return structured PowerShell objects from search for pipeline and scripting use
  • Persist alias data in YAML for cross-session usage
  • Register aliases as global functions with one refresh command
  • Support both Windows PowerShell 5.1 and PowerShell 7+

Installation

From PowerShell Gallery

For the broadest compatibility, especially on Windows PowerShell 5.1, use:

Install-Module -Name pwsh_shortcut_alias

If you already use PSResourceGet, you can also install with:

Install-PSResource -Name pwsh_shortcut_alias

If PSGallery is not registered:

Register-PSRepository -Default

Local Install From Source

  1. Copy the module folder pwsh_short_alias to the PowerShell module directory. For example:
Copy-Item -Path .\pwsh_short_alias -Destination "$HOME\Documents\PowerShell\Modules\" -Recurse -Force
  1. Import the module:
Import-Module pwsh_shortcut_alias -Force
  1. Add the following to your PowerShell profile:
### pwsh_shortcut_alias_start
if (-not (Get-Command Use-ShortcutAlias -ErrorAction SilentlyContinue)) {
    Import-Module pwsh_shortcut_alias -ErrorAction Stop
}

Use-ShortcutAlias update 6> $null
### pwsh_shortcut_alias_end

Quick Start

The alias for Use-ShortcutAlias is usa.

Add a local shortcut:

Use-ShortcutAlias add edge "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Edge.lnk"

Add a URL shortcut:

Use-ShortcutAlias add chatgpt "https://chatgpt.com/"

Refresh exported global functions:

Use-ShortcutAlias update

Launch by alias:

edge
chatgpt

Commands

Add aliases

Use-ShortcutAlias add typora "C:\Program Files\Typora\Typora.exe"
Use-ShortcutAlias add vscode "C:\Program Files\Microsoft VS Code\Code.exe"

Remove aliases

Use-ShortcutAlias remove typora

Search aliases

Use-ShortcutAlias search code

Search aliases in scripts

Use-ShortcutAlias search code | Select-Object Name, Path, IsUrl

Refresh all aliases

Use-ShortcutAlias update

Configuration File

The module creates shortcout_aliases.yaml on first use and stores alias definitions there:

aliases:
  edge:
    path: "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Edge.lnk"
  chatgpt:
    path: "https://chatgpt.com/"

Notes

  • Alias names must be unique
  • Run Use-ShortcutAlias update after adding or removing aliases before using them as commands
  • Use-ShortcutAlias search returns objects with Name, Path, and IsUrl
  • The module is compatible with Windows PowerShell 5.1 and PowerShell 7+
  • The module depends on powershell-yaml version 0.4.1 or later
  • Install-Module installs the dependency automatically; the current Gallery release of powershell-yaml still supports Windows PowerShell 5.0+, so it does not reduce this module's effective compatibility

Troubleshooting

PSGallery repository not found

If installation reports WARNING: Repository PSGallery not found, run:

Register-PSRepository -Default

Alias command is not available

If an alias exists in YAML but its command is unavailable in the current session, run:

Use-ShortcutAlias update

Examples

# Add an alias for a desktop app
Use-ShortcutAlias add wechat "C:\Program Files\Tencent\WeChat\WeChat.exe"

# Add an alias for a web app
Use-ShortcutAlias add yuque "https://www.yuque.com/"

# Rebuild exported functions
Use-ShortcutAlias update

# Launch targets
wechat
yuque

# Search for aliases in a script-friendly way
Use-ShortcutAlias search we | Select-Object Name, Path, IsUrl

Development Helpers

Install from the working tree with the helper script:

./build.ps1 install

Uninstall with:

./build.ps1 uninstall

Generate a clean publish layout for PSGallery with:

./build.ps1 stage

License

MIT License

About

A PowerShell module for managing YAML-backed shortcut aliases for apps, scripts, and URLs.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages