Files
shell-history-alias-generator/README.md
2026-02-01 08:51:28 +00:00

2.5 KiB

Shell History Alias Generator

A CLI tool that analyzes your terminal command history to automatically discover frequently used long commands and generates shell aliases for them.

Features

  • Multi-shell Support: Parse history from Bash, Zsh, and Fish shells
  • Smart Analysis: Calculate frequency scores and identify commands worth aliasing
  • Interactive Review: Review suggested aliases before adding them with a rich terminal UI
  • Multi-format Export: Export to bashrc, zshrc, or fish formats
  • Easy Installation: Direct installation to shell configuration files

Installation

pip install shell-history-alias-generator

Or from source:

git clone https://7000pct.gitea.bloupla.net/7000pctAUTO/shell-history-alias-generator.git
cd shell-history-alias-generator
pip install -e .

Usage

Analyze history and generate aliases

shell-alias-gen analyze

With a specific history file:

shell-alias-gen analyze ~/.bash_history --shell bash

Interactive mode

Review and select aliases interactively:

shell-alias-gen analyze --min-frequency 3

Export to file

shell-alias-gen analyze --export bash --output aliases.sh

Install directly to shell rc file

shell-alias-gen install --format bash

View supported shells

shell-alias-gen shells

Show history file locations

shell-alias-gen locations

Options

Option Description
--shell Shell type: bash, zsh, fish, or auto
--min-length Minimum command length (default: 15)
--min-frequency Minimum command frequency (default: 2)
--export Export format: bash, zsh, or fish
--output Output file path for export
--non-interactive Skip interactive review mode

How It Works

  1. Parse History: Reads shell history files in shell-specific formats
  2. Analyze Commands: Counts command frequency and calculates complexity scores
  3. Generate Aliases: Creates short, meaningful alias names
  4. Review: Allows interactive review of suggested aliases
  5. Export: Outputs aliases in your shell's format

Alias Name Generation

Aliases are generated based on:

  • First letters of command words (e.g., git checkoutgc)
  • Common keywords (e.g., docker, npm)
  • Minimum length and complexity requirements

Development

# Install in development mode
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

# Lint with ruff
ruff check .

License

MIT License