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
- 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+
For the broadest compatibility, especially on Windows PowerShell 5.1, use:
Install-Module -Name pwsh_shortcut_aliasIf you already use PSResourceGet, you can also install with:
Install-PSResource -Name pwsh_shortcut_aliasIf PSGallery is not registered:
Register-PSRepository -Default- Copy the module folder
pwsh_short_aliasto the PowerShell module directory. For example:
Copy-Item -Path .\pwsh_short_alias -Destination "$HOME\Documents\PowerShell\Modules\" -Recurse -Force- Import the module:
Import-Module pwsh_shortcut_alias -Force- 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_endThe 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 updateLaunch by alias:
edge
chatgptUse-ShortcutAlias add typora "C:\Program Files\Typora\Typora.exe"
Use-ShortcutAlias add vscode "C:\Program Files\Microsoft VS Code\Code.exe"Use-ShortcutAlias remove typoraUse-ShortcutAlias search codeUse-ShortcutAlias search code | Select-Object Name, Path, IsUrlUse-ShortcutAlias updateThe 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/"- Alias names must be unique
- Run
Use-ShortcutAlias updateafter adding or removing aliases before using them as commands Use-ShortcutAlias searchreturns objects withName,Path, andIsUrl- The module is compatible with Windows PowerShell 5.1 and PowerShell 7+
- The module depends on
powershell-yamlversion0.4.1or later Install-Moduleinstalls the dependency automatically; the current Gallery release ofpowershell-yamlstill supports Windows PowerShell 5.0+, so it does not reduce this module's effective compatibility
If installation reports WARNING: Repository PSGallery not found, run:
Register-PSRepository -DefaultIf an alias exists in YAML but its command is unavailable in the current session, run:
Use-ShortcutAlias update# 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, IsUrlInstall from the working tree with the helper script:
./build.ps1 installUninstall with:
./build.ps1 uninstallGenerate a clean publish layout for PSGallery with:
./build.ps1 stageMIT License