AliasMate
A powerful CLI utility to save, manage, and re-run shell commands with their working directories. Never lose track of useful commands again!

Why Use AliasMate?
As developers, we often spend time crafting complex commands, navigating to specific directories, and repeating the same sequences. AliasMate solves this by:
- Saving Time: Quickly save and rerun frequently used commands without retyping them.
- Reducing Errors: Execute commands in their correct directories, avoiding path-related mistakes.
- Boosting Productivity: Focus on coding instead of remembering command syntax and locations.
- Sharing Knowledge: Export and import commands to share workflows with your team.
- Organizing Workflows: Keep your development environment clean and organized with named, reusable commands.
Whether you're a solo developer or part of a team, AliasMate helps you streamline your terminal workflow and maintain consistency across projects.
Features
- š Save previous commands from shell history with one simple command
- š Remember working directories where commands should be executed
- šÆ Path mode selection - Choose between saved directory or current directory execution
- š Environment variable capture - Save and restore environment variables with commands
- š Security-focused - Automatic masking of sensitive variables (API keys, tokens)
- ā” Quick execution of saved commands with optional path override
- š·ļø Command aliases - Create short aliases for frequently used commands
- š Recent commands - Track and quickly re-run recent commands with @N syntax
- āļø Auto-completion - Shell completion for bash, zsh, and fish
- š Dry-run mode - Preview commands before execution with --dry-run flag
- ā
Command validation - Verify commands and directories when saving
- š Output formatting - Multiple formats (JSON, YAML, table, compact)
- š Interactive save with prompts for command and path
- š List all saved commands with their details
- š Search commands by name, text, or directory
- āļø Edit commands interactively with environment variable management
- šļø Delete unwanted commands
- š¤ Export/Import commands for backup or sharing
- š Changelog viewer - View version history and cumulative changes
- š¤ LLM Integration - Default command to generate comprehensive documentation
- š Onboarding experience - Welcome tour and upgrade notifications
- šØ Beautiful colored output for better readability
- š Cross-platform support (Linux, macOS, Windows)
Installation
Install globally via npm:
npm i -g aliasmate
Shell Completion (Optional)
AliasMate supports auto-completion for bash, zsh, and fish shells. This provides tab completion for commands, saved command names, and flags.
š Quick Install (Recommended)
The easiest way to install completion is to use the auto-installer:
aliasmate completion install
This will:
- Auto-detect your shell (bash/zsh/fish)
- Add the completion script to your shell config
- Show you how to reload your shell
Manual Installation
If you prefer manual installation or the auto-installer doesn't work for your setup:
Bash
Add to your ~/.bashrc:
source <(aliasmate completion bash)
Then reload:
source ~/.bashrc
Zsh
Add to your ~/.zshrc:
source <(aliasmate completion zsh)
Then reload:
source ~/.zshrc
Fish
Generate the completion file:
aliasmate completion fish > ~/.config/fish/completions/aliasmate.fish
Fish will automatically load it on next shell start.
What Gets Completed
- Main commands (run, list, save, etc.)
- Your saved command names
- Command flags and options
- File paths for import/export
- Format options (json, yaml, table, compact)
Example:
aliasmate ru<TAB>
aliasmate run bu<TAB>
aliasmate list --fo<TAB>
Shell Configuration (Recommended)
For aliasmate prev to work reliably and capture commands immediately, configure your shell to write history in real-time:
For zsh users (macOS default, Linux):
Add to ~/.zshrc:
setopt INC_APPEND_HISTORY
Then reload:
source ~/.zshrc
For bash users (Linux default, macOS optional):
Add to ~/.bashrc:
PROMPT_COMMAND="history -a"
Then reload:
source ~/.bashrc
Why is this needed?
Without this configuration, shells only write commands to the history file when the shell exits. This means:
- If you run
npm run dev and press ^C to cancel it, then immediately run aliasmate prev, the command won't be in the history file yet
- You'll see older commands captured instead (like
clear or previous commands)
With this configuration, every command is written to history immediately after execution, making aliasmate prev work perfectly every time.
Alternative: Use aliasmate save
If you prefer not to configure shell history, you can always use the interactive save:
aliasmate save
Getting Started
Usage
Save the Previous Command
Automatically capture the last command you ran:
aliasmate prev <name>
Example:
npm run build
aliasmate prev build
Run a Saved Command
Execute a saved command in its original directory:
aliasmate run <name>
Or override the directory:
aliasmate run <name> .
aliasmate run <name> /path/to/another/project
Dry-run mode (preview without executing):
aliasmate run <name> --dry-run
aliasmate run <name> --dry-run --verbose
Run recent commands by index:
aliasmate run @0
aliasmate run @1
Example:
aliasmate run build
Save a Command Interactively
Manually save a command with interactive prompts:
aliasmate save
You'll be prompted for:
- Command name
- Command to save
- Working directory (defaults to current directory)
- Path mode (NEW): Choose whether to run in saved directory or current directory
Path Mode Feature
AliasMate now supports two path modes for each saved command:
Saved Directory Mode (Default)
Commands always run in the directory where they were saved. Perfect for project-specific commands.
cd /path/to/my-project
npm run build
aliasmate prev build
cd ~
aliasmate run build
Current Directory Mode
Commands run in your current working directory. Ideal for general-purpose utilities.
aliasmate save
cd /path/to/project-a
aliasmate run lint
cd /path/to/project-b
aliasmate run lint
You can change the path mode anytime using aliasmate edit <name>.
Generate LLM Documentation
AliasMate includes a default command that generates comprehensive documentation for AI assistants:
aliasmate run llm
This creates an llm.txt file in your current directory containing:
- Complete feature documentation
- All available commands and their usage
- Best practices and examples
- Integration tips for AI assistants
Share this file with AI assistants like ChatGPT or Claude for better help with AliasMate!
List All Saved Commands
View all your saved commands:
aliasmate list
aliasmate ls
Output:
Saved commands (3):
build
Command: npm run build
Directory: /path/to/project
deploy
Command: ./deploy.sh
Directory: /path/to/scripts
test
Command: pytest tests/
Directory: /path/to/python-project
Edit a Saved Command
Modify an existing command:
aliasmate edit <name>
Opens an interactive prompt to edit the command and directory.
Delete a Saved Command
Remove a command you no longer need:
aliasmate delete <name>
aliasmate rm <name>
Export Commands
Backup your commands to a JSON file:
aliasmate export commands.json
Import Commands
Restore commands from a JSON file:
aliasmate import commands.json
If there are name conflicts, you'll be prompted to:
- Overwrite existing commands
- Skip imported commands
- Rename imported commands
View Config Location
See where your commands are stored:
aliasmate config
Environment Variables
AliasMate can capture and restore environment variables along with your commands:
Capturing Environment Variables
When saving commands with prev or save, you'll be prompted to capture environment variables:
NODE_ENV=production npm run build
aliasmate prev build-prod
What Gets Captured:
- ā
User-defined environment variables (like
NODE_ENV, API_URL, DEBUG)
- ā System variables are filtered out (like
PATH, HOME, USER)
- š Sensitive variables are automatically detected and masked
Security Features
- Automatic Detection: Sensitive variables containing keywords like
KEY, SECRET, TOKEN, PASSWORD are automatically identified
- Masked Exports: When exporting, sensitive values are masked (e.g.,
API_KEY=abc***xy)
- Safe Sharing: Share command exports with your team without exposing secrets
Managing Environment Variables
aliasmate edit build-prod
aliasmate list
Use Cases:
- Development/staging/production environment switching
- API testing with different endpoints and tokens
- Tool configuration (e.g.,
DEBUG=*, VERBOSE=true)
- Multi-environment deployments
Example:
NODE_ENV=development API_URL=http://localhost:3000 npm start
aliasmate prev dev-server
aliasmate run dev-server
Version History & Changelog
View what's new and see changes between versions:
aliasmate changelog
aliasmate changelog --ver 1.3.0
aliasmate changelog --from 1.2.0 --to 1.4.0
aliasmate changelog --from 1.2.0
Automatic Upgrade Notifications:
When you upgrade AliasMate, you'll automatically see:
- Summary of new features and improvements
- Cumulative changes since your last version
- Links to full documentation
This ensures you never miss important features or fixes when upgrading!
Command Aliases
Create short aliases for frequently used saved commands:
aliasmate alias b build
aliasmate alias d deploy-prod
aliasmate alias --list
aliasmate alias --remove b
Features:
- Keyboard-friendly shortcuts for long command names
- Validates against reserved command names
- Shows both alias and original command when executing
- Stored separately from commands in metadata
Example:
aliasmate alias b build
aliasmate alias t test
aliasmate alias dp deploy-prod
aliasmate run b
aliasmate run @0
Recent Commands
Track and quickly re-run recently executed commands:
aliasmate recent
aliasmate recent --limit 10
aliasmate recent --clear
Quick re-execution with @N syntax:
aliasmate run @0
aliasmate run @1
aliasmate run @2
Features:
- Automatic execution tracking
- Deduplicated display (shows unique commands)
- Shows last run time and execution count
- Configurable history size (default: 50)
- Time-ago formatting (e.g., "2 minutes ago")
Dry-Run Mode
Preview what will execute before running a command:
aliasmate run build --dry-run
aliasmate run build --dry-run --verbose
What you'll see:
- Full command to be executed
- Working directory
- Path mode (saved/current/overridden)
- Environment variables (with sensitive values masked)
- Dangerous command warnings (rm -rf, dd, etc.)
Example output:
š DRY RUN MODE - Command will NOT be executed
Command:
npm run build --production
Working Directory:
/path/to/project
Path Mode:
saved
Environment Variables:
3 variable(s) will be loaded
NODE_ENV=production
API_URL=https://api.example.com
API_KEY=abc***xyz (masked)
ā ļø WARNING: This command may be dangerous
To execute, run without --dry-run flag
Command Validation
Validate commands when saving to catch errors early:
aliasmate validate build
aliasmate validate --all
aliasmate save --no-validate
aliasmate edit <name> --no-validate
What gets validated:
- Command existence: Checks if command is in PATH or is a shell builtin
- Directory existence: Verifies directory exists and is accessible
- Shell syntax: Basic syntax validation (quotes, brackets, pipes)
- Environment variables: Validates variable name patterns
Validation types:
- Errors: Block command execution (red)
- Command not found
- Directory doesn't exist
- Invalid syntax
- Warnings: Allow execution with notice (yellow)
- Undefined environment variables
- Non-executable file paths
Example:
$ aliasmate validate build
Validating command: build
ā No issues found
Command: npm run build
Directory: /path/to/project
Environment Variables: 2
$ aliasmate validate --all
Validating 15 saved commands...
ā 13 commands passed validation
ā 2 commands have warnings
Commands with issues:
deploy: Warning - Command 'deploy.sh' not found in PATH
Output Formatting
Export or view commands in multiple formats:
aliasmate list --format table
aliasmate list --format json
aliasmate list --format yaml
aliasmate list --format compact
aliasmate export commands.json --format json
aliasmate export commands.yaml --format yaml
Format examples:
JSON:
{
"build": {
"command": "npm run build",
"directory": "/path/to/project",
"pathMode": "saved",
"env": { "NODE_ENV": "production" },
"createdAt": "2026-01-22T10:00:00Z"
}
}
YAML:
build:
command: "npm run build"
directory: "/path/to/project"
pathMode: saved
env:
NODE_ENV: "production"
createdAt: "2026-01-22T10:00:00Z"
Compact:
build: npm run build (/path/to/project)
test: npm test (/path/to/project)
deploy: ./deploy.sh (/path/to/scripts)
Use cases:
- CI/CD integration (JSON/YAML)
- Scripting and automation
- Quick scanning (compact)
- Team sharing with sensitive data masked
Configuration
Commands are stored in:
- Linux/macOS:
~/.config/aliasmate/config.json
- Windows:
%USERPROFILE%\.config\aliasmate\config.json
Command Reference
aliasmate prev <name> | - | Save the previous command from shell history (with optional env vars) |
aliasmate run <name> [path] | - | Run a saved command (restores env vars, optionally override directory) |
aliasmate run @N | - | Run Nth recent command (e.g., @0 = most recent) |
aliasmate run <name> --dry-run | - | Preview command without executing |
aliasmate save | - | Interactively save a new command (with optional env vars) |
aliasmate save --no-validate | - | Save command without validation |
aliasmate list | ls | List all saved commands (shows env var indicators) |
aliasmate list --format <type> | - | List in different formats (table/json/yaml/compact) |
aliasmate search <query> | find | Search for commands by name, text, or directory |
aliasmate edit <name> | - | Edit a saved command (manage env vars, path mode, etc.) |
aliasmate edit <name> --no-validate | - | Edit command without validation |
aliasmate delete <name> | rm | Delete a saved command |
aliasmate export <file> | - | Export commands to a file (sensitive vars masked) |
aliasmate export <file> --format <type> | - | Export in JSON or YAML format |
aliasmate import <file> | - | Import commands from a file (auto backup) |
aliasmate alias <short> <command> | - | Create alias for a command |
aliasmate alias --list | - | List all aliases |
aliasmate alias --remove <alias> | - | Remove an alias |
aliasmate recent | - | Show recently executed commands |
aliasmate recent --limit <N> | - | Limit recent commands displayed |
aliasmate recent --clear | - | Clear execution history |
aliasmate validate <name> | - | Validate a single command |
aliasmate validate --all | - | Validate all saved commands |
aliasmate completion install | - | Auto-install shell completion for your shell |
aliasmate completion <shell> | - | Generate shell completion script (bash, zsh, fish) |
aliasmate changelog | changes | View version changelog and release notes |
aliasmate config | - | Show config file location and command count |
Examples
Common Workflows
1. Save and reuse a build command:
cd /my/project
npm run build -- --production
aliasmate prev build-prod
aliasmate run build-prod
2. Save a deployment script:
aliasmate save
3. Run a command in a different directory:
aliasmate run test /path/to/different/project
4. Backup your commands:
aliasmate export ~/backups/aliasmate-$(date +%Y%m%d).json
5. Share commands with your team:
aliasmate export team-commands.json
aliasmate import team-commands.json
Tips
- Use descriptive names for your commands (e.g.,
build-prod, test-unit, deploy-staging)
- Regularly export your commands as backup
- The
prev command is great for saving complex commands you just figured out
- Use path override to run the same command in multiple projects
Troubleshooting
"Could not retrieve previous command from history"
This happens when shell history is disabled or the command hasn't been written to the history file yet.
Common scenario: You run a command, press ^C to cancel it, and immediately run aliasmate prev, but it captures an older command (like clear) instead.
Why: Most shells only write to history when the shell exits, not after each command.
Solution: Configure real-time history writing (see Shell Configuration above):
- zsh: Add
setopt INC_APPEND_HISTORY to ~/.zshrc
- bash: Add
PROMPT_COMMAND="history -a" to ~/.bashrc
Quick fix: Close and reopen your terminal, then try the command again.
Alternative: Use aliasmate save to enter commands manually.
Commands not executing properly
- Verify the saved directory exists:
aliasmate list
- Check if the command requires environment variables or specific shell configuration
- Try running the command manually in the saved directory first
History file not found
Make sure your shell history is enabled:
- Check for
~/.zsh_history (zsh) or ~/.bash_history (bash)
- If missing, history may be disabled - check your shell configuration files
Development
To work on AliasMate locally:
git clone https://github.com/aliasmate/aliasmate.git
cd aliasmate
npm install
npm run build
npm run typecheck
npm run lint
npm run format
npm link
aliasmate --help
Development Scripts
npm run build | Compile TypeScript to JavaScript |
npm run dev | Watch mode for development |
npm run typecheck | Run TypeScript type checking |
npm run lint | Check code quality with ESLint |
npm run lint:fix | Auto-fix ESLint issues |
npm run format | Format code with Prettier |
npm run format:check | Check if code is formatted |
Code Quality
AliasMate is built with modern development practices:
- ā
TypeScript with strict mode enabled
- ā
ESLint for code quality enforcement
- ā
Prettier for consistent formatting
- ā
Comprehensive JSDoc documentation
- ā
Centralized error handling with proper exit codes
- ā
Zero type safety warnings in production code
For detailed contribution guidelines, see CONTRIBUTING.md.
Project Structure
aliasmate/
āāā src/
ā āāā cli.ts # CLI entry point
ā āāā commands/ # Command implementations
ā ā āāā prev.ts # Save from history
ā ā āāā run.ts # Execute commands
ā ā āāā save.ts # Interactive save
ā ā āāā list.ts # Display all
ā ā āāā edit.ts # Modify commands
ā ā āāā delete.ts # Remove commands
ā ā āāā export.ts # Backup to JSON
ā ā āāā import.ts # Restore from JSON
ā āāā storage/
ā ā āāā index.ts # Config persistence
ā āāā utils/
ā āāā constants.ts # Shared constants
ā āāā errors.ts # Error handling
ā āāā executor.ts # Command execution
ā āāā history.ts # Shell integration
ā āāā paths.ts # Path utilities
āāā dist/ # Compiled output
āāā docs/
āāā CONTRIBUTING.md # Contributor guide
āāā DEV_GUIDE.md # Quick reference
āāā CLEANUP_SUMMARY.md # Code quality report
License
MIT
Contributing
Contributions are welcome! We appreciate:
- š Bug reports and fixes
- ⨠Feature suggestions and implementations
- š Documentation improvements
Maintainer: AliasMate Contributors
Changelog
See CHANGELOG.md for version history and release notes.
Support
ā If you find AliasMate helpful, please consider giving it a star on GitHub!
- šØ Code quality enhancements
Before contributing, please:
- Read our Contributing Guide
- Check existing issues and pull requests
- Follow the code style (ESLint + Prettier)
- Add tests for new features (when applicable)
- Update documentation as needed
Quick Start for Contributors
git clone https://github.com/YOUR_USERNAME/aliasmate.git
cd aliasmate
npm install
npm run format
npm run lint
npm run typecheck
npm run build
npm link
aliasmate --help
See DEV_GUIDE.md for detailed development workflows.
Author
Created with ā¤ļø for developers who love productivity tools.