oh-my-alias
v1.0.8
Published
A simple and powerful command-line interface (CLI) tool built with TypeScript, yargs, and @inquirer/prompts to help you manage your shell aliases efficiently. Stop cluttering your .bashrc or .zshrc directly and let oh-my-alias handle your alias collection
Maintainers
Readme
Oh-My-Alias CLI
A simple and powerful command-line interface (CLI) tool built with TypeScript, yargs, and @inquirer/prompts to help you manage your shell aliases efficiently. Stop cluttering your .bashrc or .zshrc directly and let oh-my-alias handle your alias collection!
Features
- Easy Alias Management: Add, list, and remove shell aliases with intuitive commands.
- Persistent Storage: Aliases are stored in a clean JSON file in your home directory (~/.oh-my-alias/aliases.json).
- Shell Integration: Generates a shell script (~/.oh-my-alias/aliases.sh) that you can easily source in your shell's configuration file for seamless access to your aliases.
- Global Options: Supports short flags like oma -l to quickly list aliases.
Installation
Install oh-my-alias globally:
npm install -g oh-my-aliasUsage
1. Initialize the CLI
First, you need to initialize oh-my-alias to set up its configuration files and integrate with your shell.
oma init
Follow the on-screen instructions. This command will:
- Create the ~/.oh-my-alias/ directory.
- Create an empty ~/.oh-my-alias/aliases.json file to store your aliases.
- Generate the ~/.oh-my-alias/aliases.sh script.
- Crucially, it will tell you to add a line like source "~/.oh-my-alias/aliases.sh" to your shell's configuration file (e.g., ~/.bashrc, ~/.zshrc, ~/.profile). You only need to do this once.
After adding the source line, remember to reload your shell configuration (e.g., source ~/.bashrc) or open a new terminal session for the changes to take effect.
2. Managing Aliases
Once initialized, you can use oh-my-alias to manage your aliases:
Add an Alias
oma add <alias-name> "<command-to-alias>"
# Example:
oma add gcl "git clone --depth 1"
oma add gs "git status -sb"
If an alias already exists, oh-my-alias will prompt you for confirmation before overwriting it.
List All Aliases
oma list
# Or using the shorthand flag:
oma -l
This will display all aliases currently stored in your aliases.json file.
Remove an Alias
oma remove <alias-name>
# Example:
oma remove gcl
```oh-my-alias` will ask for confirmation before permanently removing an alias.
#### Synchronize Shell Aliases Script
Normally, `oma add` and `oma remove` automatically update the `aliases.sh` script. However, if you manually edit `~/.oh-my-alias/aliases.json` or suspect an issue, you can force a synchronization:
```bash
oma sync
After running oh-my-alias sync, you will still need to re-source your shell configuration (e.g., source ~/.bashrc) for the changes to become active in your current terminal session.
Run an Alias (for testing purposes)
While you'll typically run aliases directly in your shell after sourcing, you can use the run command to test them:
oma run <alias-name> [additional arguments...]
# Example:
oma run gcl my-repo-url
Configuration
The oh-my-alias stores its configuration and aliases in your home directory:
- Configuration Directory: ~/.oh-my-alias/
- Aliases Data File: ~/.oh-my-alias/aliases.json (a JSON file containing key-value pairs of alias name and command)
- Shell Integration Script: ~/.oh-my-alias/aliases.sh (the script generated by oh-my-alias that you source in your shell config)
Contributing
Contributions are welcome! If you have suggestions, bug reports, or want to contribute code, please open an issue or pull request on the GitHub repository.
License
This project is licensed under the MIT License - see the LICENSE file for details.
