Skip to content

Repository files navigation

aliasfight ⚔️

Turn your terminal habits into enemies and defeat them with aliases.

Python License Status CLI

✨ Features

  • First-run setup with persistent config at ~/.aliasfight/config.json
  • Multi-provider AI narration:
    • OpenAI (gpt-4o-mini)
    • OpenRouter (openrouter/auto)
    • Gemini (gemini-1.5-flash)
  • Environment variable override support:
    • OPENAI_API_KEY
    • OPENROUTER_API_KEY
    • GEMINI_API_KEY
  • Battle analysis from shell history:
    • repeated commands
    • long commands (>30 chars)
    • git frequency
    • repeated cd navigation
  • Rich UI with ASCII banner, enemies panel, upgrades panel, and narration panel
  • AI failure-safe fallback narration when API/network fails

🚀 Installation

python -m pip install .
aliasfight

For editable local development:

pip install -r requirements.txt
python -m aliasfight

🛠 First Run Setup

On first run, aliasfight asks:

Choose your AI provider:
1. OpenAI
2. OpenRouter
3. Gemini
4. Skip (no AI)
API key (hidden input):

If the key is wrong or cannot be validated, aliasfight tells you and asks you to paste it again.

Then it saves:

{
	"provider": "openai",
	"api_key": "xxxx"
}

at ~/.aliasfight/config.json.

Config priority:

  1. Environment variables
  2. Saved config file
  3. First-run setup prompt

🤖 Supported AI Providers

  • OpenAI via official openai package
  • OpenRouter via requests to /chat/completions
  • Gemini via google-generativeai

📦 Usage

aliasfight
aliasfight --no-ai
aliasfight --reset-config
aliasfight --add-api
aliasfight --history ~/.zsh_history

# module mode still works
python -m aliasfight
python -m aliasfight --no-ai
python -m aliasfight --reset-config
python -m aliasfight --add-api
python -m aliasfight --history ~/.zsh_history

aliasfight remembers your provider/key in ~/.aliasfight/config.json, so you usually do not need export ... commands. Use environment variables only if you want a temporary override.

⚔️ Example CLI Interaction

$ python -m aliasfight --reset-config
[yellow]Existing config removed.[/yellow]
Choose your AI provider:
1. OpenAI
2. OpenRouter
3. Gemini
4. Skip (no AI)
Enter choice: 2
API key (hidden input): **************
Summoning openrouter narrator...

🎨 Custom ASCII Banner

To use your own large ASCII art banner, create:

mkdir -p ~/.aliasfight
nano ~/.aliasfight/banner.txt

Paste your ASCII art there. aliasfight auto-loads it at startup.

🎭 AI Roast Prompt

You are a dramatic RPG narrator. Turn these terminal habits into enemies, roast them humorously, and present alias upgrades as power-ups.

If AI is disabled, unconfigured, or fails due to invalid keys/network issues, aliasfight still prints a full battle report with fallback narration.

About

Your terminal history gets turned into a battle between YOU and your bad habits

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages