Skip to content

Pranav435/alias-gen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alias-gen

A humble command-line helper for your shell. alias-gen watches your command history, spots the sequences you repeat, and turns them into simple, memorable shortcuts—so you can focus on your work instead of your typing.


Why I Built This

I kept finding myself typing the same long command chains—sometimes dozens of keystrokes—just to get simple tasks done. It felt backward, like I was teaching the computer instead of the other way around. alias-gen learns from your own history and suggests concise aliases or tiny functions that fit how you work.


Quickstart

  1. Download and install curl -sSL https://github.com/Pranav435/alias-gen/raw/v1.0.0/install.sh | bash
  2. Configure your OpenAI API key and choose a UI alias_gen config
  3. Preview what alias-gen found alias_gen scan
  4. Merge your favorites into your shell alias_gen install
  5. Activate the new shortcuts open a new shell or run source ~/.bashrc (or the RC file for your shell)

How It Works

alias-gen combines straightforward heuristics with a dash of AI to suggest shortcuts you’ll actually use:

  1. Load your history • Reads up to the last 10 000 commands from your shell’s history (bash, zsh, fish) or PowerShell’s PSReadLine log • Drops blank lines and exact duplicates—so you get real patterns, not noise

  2. Detect repeating sequences • Uses “sliding windows” of length 1, 2, and 3 to collect command sequences • Counts occurrences: only keeps pairs/triplets that appear at least 3 times by default • Single-command rules: a one-liner must either be at least 30 characters long or contain multiple tokens • Filters out trivial commands: skips simple built-ins like ls, pwd, echo or any patterns you’ve asked to ignore (brew install, curl -fsSL, etc.) • Whitelists special workflows: sequences like cd project && source venv/bin/activate get through even if rare • Normalizes paths: turns cd ~/projects/foo into cd foo, so your alias is reusable across directories • Deduplicates by normalized form and ranks by frequency

  3. Generate suggestions with AI • Packages the top patterns into a single prompt for GPT-4-mini (or your chosen model) with a clear system message • Receives back alias definitions or small shell functions, e.g.: alias gs='git status' # check git status in one keystroke function go() { cd "$1"; ls; } # jump into a folder and list • You can tweak model, temperature, token limits and ignore-patterns via alias_gen config

  4. Safely install into your shell • Backs up your RC file (~/.bashrc, ~/.zshrc, etc.) with a timestamp • Inserts or updates the block between

    alias-gen start

    …your new aliases…

    alias-gen end

    • Leaves everything else untouched—so you can review, revert or adjust by hand


Flags & Options

alias_gen [--history-file PATH] [--ui terminal|tui|web]

• --history-file PATH  use a custom history file instead of the default • --ui MODE  override saved UI mode (terminal, tui, or web)

Actions

• config  set or update your OpenAI API key and UI mode • scan  preview AI-generated alias suggestions without writing to your shell • install  apply selected aliases/functions to your RC file • edit  review, rename or delete entries in your alias-gen block • manual  enter a custom alias or function by hand


Everyday Workflow

• Preview suggestions: alias_gen scan

• Install them: alias_gen install

• Tweak what’s there: alias_gen edit

• Reconfigure or switch UI: alias_gen config


Building from Source

  1. git clone https://github.com/Pranav435/alias-gen.git
  2. cd alias-gen
  3. pip install --user openai InquirerPy flask pyinstaller
  4. pyinstaller --onefile alias_gen.py (executable appears at dist/alias_gen)

Contributing & Support

Bugs, ideas or pull requests? Open an issue or send a PR: https://github.com/Pranav435/alias-gen


Contact & Community

YouTube: https://youtube.com/@imtheblindiephoenix Twitter: https://twitter.com/blindiephoenix


Donations

I’m a college student with limited funds. If alias-gen saves you time (or typos), any support helps keep me coding (and caffeinated):

https://paypal.me/theblindiephoenix

Thank you for trying alias-gen!

About

An automatic alias generator for shell and bash terminals using GPT.

Resources

License

Stars

Watchers

Forks

Packages

No packages published