Fast, persistent command aliases for Windows that work exactly like native commands.
✓ Native behavior - Works in cmd.exe, PowerShell, Git Bash, any terminal
✓ Persistent - Survives restarts and terminal sessions
✓ Fast - 21x faster than .bat files (0.75ms vs 15ms per execution)
✓ Reliable - Works correctly with arguments in automation scripts
✓ Auto-install - Adds itself to PATH automatically
✓ Simple - 200 lines of Python, 200 lines of C
pip install git+https://github.com/offerrall/PyAlias-Windows-Alias-ManagerRequirements:
- Windows
- Python 3.10+
- gcc (MinGW-w64) - Download here
On first run, PyAlias automatically adds ~/.pyalias to your PATH. Restart your terminal after installation.
# Create aliases
pyalias new ls "dir /b"
pyalias new gs "git status"
pyalias new gp "git push"
pyalias new dev "cd C:\projects && npm run dev"
# Use them
ls
gs
gp origin main
# Manage
pyalias list
pyalias read ls
pyalias delete lspyalias new <alias> <command> # Create alias
pyalias list # List all aliases
pyalias read <alias> # Show alias command
pyalias delete <alias> # Delete alias
pyalias -h # HelpYou might wonder: "Windows already supports .bat files, why do I need this?"
.bat files have critical limitations:
-
20x slower - Batch files take ~15ms to execute vs ~0.75ms for
.exe -
Arguments break in automation -
.batfiles don't pass arguments correctly when called from Python'ssubprocess- Your automation scripts will fail
.exeworks reliably everywhere
-
Batch syntax quirks - Need
@echo off, special escaping for%,&,|.exejust runs the command directly
Benchmark from real tests:
100 executions in cmd.exe:
.exe: 75ms (0.75ms each)
.bat: 1579ms (15.79ms each)
Result: .exe is 21x faster
When you create an alias:
- PyAlias copies
launcher.exe→~/.pyalias/ls.exe - Creates
~/.pyalias/ls.txtcontaining the command - Adds
~/.pyaliasto your PATH (once)
When you run the alias:
- Windows finds
ls.exein PATH ls.exereads its own filename: "ls"- Opens
ls.txtin the same directory - Executes the command with any arguments you passed
User types: ls -la
Executes: ls.exe → reads ls.txt ("dir /b") → runs "dir /b -la"
The launcher is written in C for speed and reliability:
- Instant execution - No interpreter overhead like batch files
- Static memory - No malloc, deterministic behavior
- Robust - Handles long paths (32KB), large commands (8KB)
- Portable - Single 20KB executable per alias
Launcher architecture:
- Static memory allocation (no malloc)
- 32KB path buffer (handles Windows long paths)
- 8KB command buffer (practically unlimited)
- Error handling with specific messages
Storage:
- Aliases stored in
C:\Users\YourName\.pyalias\ - Each alias is one
.exe+ one.txtfile - 50 aliases = ~1MB total
These are inherent to how subprocesses work, not PyAlias limitations:
- Can't change directory -
cdin a subprocess doesn't affect the parent shell - Can't modify environment -
set VAR=valueonly affects the subprocess
For these use cases, use shell-specific solutions (.bashrc, PowerShell profiles, etc.)
Pull requests welcome. Keep it simple and fast.
MIT