Shell History Alias Generator

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

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
  • 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:

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

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

License

MIT

Description
A CLI tool that analyzes terminal command history to discover frequently used long commands and generates shell aliases
Readme 77 KiB
Languages
Python 100%