UNPKG

aahook

Version:

A CLI tool that displays ASCII art when commands succeed or fail

373 lines (287 loc) โ€ข 8.29 kB
# ๐ŸŽฏ aahook ![npm](https://img.shields.io/npm/dw/aahook) <!-- ้€ฑใ”ใจใฎDLๆ•ฐ --> ![npm](https://img.shields.io/npm/dm/aahook) <!-- ๆœˆใ”ใจใฎDLๆ•ฐ --> ![npm](https://img.shields.io/npm/dt/aahook) <!-- ็ดฏ่จˆDLๆ•ฐ --> Display ASCII art when your commands succeed or fail! Make your terminal more fun and expressive. ```bash # Install-free usage with npx or bunx npx aahook git push # Shows dragon art on success ๐Ÿฒ bunx aahook npm test # Shows success/error art based on result โœจ ``` ## โœจ Features - ๐ŸŽจ Show custom ASCII art based on command success/failure - ๐ŸŒˆ **NEW: Color themes** - Apply beautiful colors to your ASCII arts - ๐Ÿ“ฅ Browse and install ASCII arts from community repository - ๐ŸŒ GitHub-based art sharing - contribute via Pull Requests - โšก Zero dependencies, lightweight and fast - ๐Ÿ”ง Easy configuration with JSON - ๐Ÿ“ฆ Simple npm installation - ๐ŸŽฏ Customizable art files - ๐Ÿ” Preview arts before installation ## ๐Ÿ“ฆ Installation ### ๐Ÿš€ No Installation Required (Recommended) ```bash # Using npx (comes with Node.js) npx aahook <command> # Using bunx (faster, comes with Bun) bunx aahook <command> ``` ### Optional: Global Installation <details> <summary>If you prefer to install globally...</summary> #### Using npm ```bash npm install -g aahook ``` #### Using Bun ```bash bun add -g aahook # Add to PATH (first time only) echo 'export PATH="$HOME/.bun/bin:$PATH"' >> ~/.zshrc source ~/.zshrc ``` </details> ## ๐Ÿš€ Quick Start 1. **Initialize aahook:** ```bash npx aahook init # or bunx aahook init ``` 2. **Run commands with ASCII art:** ```bash # Using npx npx aahook ls # Shows cat art on success ๐Ÿฑ npx aahook git push # Shows dragon art on success ๐Ÿฒ npx aahook npm test # Shows success/error art โœจ/๐Ÿ’ฅ # Using bunx (faster) bunx aahook ls bunx aahook git push bunx aahook npm test ``` ## ๐Ÿ“ Usage ### Basic Commands ```bash npx aahook <command> # Execute command and show ASCII art npx aahook init # Initialize aahook configuration npx aahook list # List configured hooks npx aahook --help # Show help message npx aahook --version # Show version ``` ### ASCII Art Management ```bash # Browse available arts in the repository npx aahook browse # Preview an art before installing npx aahook preview animals/cat --remote # Install an art from the repository npx aahook install animals/cat npx aahook install celebrations/party --auto-config # View your installed arts npx aahook gallery npx aahook gallery --category animals --limit 5 # Preview installed art npx aahook preview cat ``` ### ๐ŸŒˆ Color Themes (NEW!) ```bash # List available color themes npx aahook colorize --list-themes # Apply a color theme to an ASCII art npx aahook colorize cat --theme rainbow npx aahook colorize dragon --theme neon npx aahook colorize party --theme fire # Save the colored version npx aahook colorize cat --theme ocean --save # Use custom theme npx aahook colorize cat --custom ./my-theme.json # Available built-in themes: # - rainbow: Colorful gradient for each line # - neon: Bright cyberpunk colors # - ocean: Cool blue tones # - fire: Warm red and orange # - retro: Classic green terminal ``` #### Creating Custom Themes Create your own color themes! See [Theme Creation Guide](docs/CREATE_THEME.md) for details. Quick example - create `~/.aahook/themes/my-theme.json`: ```json { "name": "my-theme", "version": "1.0.0", "colors": { "mode": "line", "rules": [ { "match": { "start": 0, "end": 0 }, "color": { "fg": "#FF6B6B" } } ] } } ``` Then use it: ```bash npx aahook colorize cat --theme my-theme ``` ### ๐ŸŽฌ Animations (NEW!) ```bash # Animate ASCII art with various effects npx aahook animate cat --type typing --speed 50 npx aahook animate dragon --type fade --direction top npx aahook animate success --type slide --direction left # Animation types: # - typing: Display characters one by one # - fade: Fade in lines or characters gradually # - slide: Slide art from specified direction # - frames: Animate through multiple frames # - blink: Make art or parts of it blink # Combine with color themes npx aahook animate cat --type typing --theme rainbow # Control animation speed npx aahook animate cat --type typing --speed 100 # Faster npx aahook animate cat --type typing --speed 20 # Slower # Fade directions npx aahook animate dragon --type fade --direction top # Top to bottom npx aahook animate dragon --type fade --direction bottom # Bottom to top npx aahook animate dragon --type fade --direction left # Left to right (character by character) npx aahook animate dragon --type fade --direction right # Right to left # Save animation settings npx aahook animate cat --type typing --save ``` ### Real-world Examples ```bash # Development workflow npx aahook npm test # Run tests with visual feedback bunx aahook npm run build # Build with success animation npx aahook git push # Push code with dragon celebration # File operations bunx aahook ls -la # List files with cat art npx aahook rm temp.txt # Delete with feedback # Quick aliases (add to .zshrc/.bashrc) alias aa="npx aahook" # Now use: aa npm test alias aab="bunx aahook" # Now use: aab git push ``` ## โš™๏ธ Configuration Configuration is stored in `~/.aahook/config.json`: ```json { "version": "0.1.0", "hooks": { "git push": { "success": "dragon.txt", "error": "error.txt" }, "ls": { "success": "cat.txt" }, "npm test": { "success": "success.txt", "error": "error.txt" } } } ``` ## ๐ŸŽจ Available ASCII Arts ### Browse All Available Arts ```bash npx aahook browse # See all available arts in repository ``` ### Categories - ๐Ÿพ **Animals**: cat, dog, and more - ๐ŸŽ‰ **Celebrations**: success, party themes - ๐Ÿ’ป **Developer**: dragon, deploy, coding themes - ๐Ÿ˜Š **Emotions**: happy, surprised, error expressions ### Example Arts #### Cat (animals/cat) ``` ๐Ÿฑ Done! ๐Ÿฑ /\_/\ ( o.o ) > ^ < ``` #### Dragon (developer/dragon) ``` ๐Ÿฒ Push successful! ๐Ÿฒ /| /| ( :v: ) |(_)| Your code flies to the repo! ``` #### Party (celebrations/party) ``` ๐ŸŽ‰ Let's celebrate! ๐ŸŽ‰ \o/ | / \ *confetti* ``` ## ๐ŸŽฏ Custom Art ### Method 1: Install from Repository ```bash # Browse available arts npx aahook browse # Install specific art npx aahook install animals/cat npx aahook install developer/deploy --auto-config ``` ### Method 2: Create Your Own 1. Create your ASCII art file in `~/.aahook/arts/` 2. Update `~/.aahook/config.json` to use your art: ```json { "hooks": { "your-command": { "success": "your-art.txt", "error": "your-error-art.txt" } } } ``` ### Method 3: Contribute to Repository 1. Fork the [aahook repository](https://github.com/MidoriTakahashi77/aahook) 2. Add your art to `arts/<category>/<name>.txt` 3. Update `arts/<category>/META.json` with art metadata 4. Submit a Pull Request to share with the community! ## ๐Ÿ“ File Structure ``` ~/.aahook/ โ”œโ”€โ”€ config.json # Hook configuration โ””โ”€โ”€ arts/ # ASCII art files โ”œโ”€โ”€ success.txt โ”œโ”€โ”€ error.txt โ”œโ”€โ”€ dragon.txt โ””โ”€โ”€ cat.txt ``` ## ๐Ÿงช Development ```bash # Clone the repository git clone https://github.com/MidoriTakahashi77/aahook.git cd aahook # Install dependencies (choose one) npm install bun install # Build TypeScript npm run build bun run build # Run tests npm test bun test # Test locally without publishing npm link # Then use: aahook <command> # or test directly node bin/aahook.js --version ``` ## ๐Ÿค Contributing Contributions are welcome! Feel free to: 1. Fork the repository 2. Create your feature branch (`git checkout -b feature/amazing-feature`) 3. Commit your changes (`git commit -m 'Add amazing feature'`) 4. Push to the branch (`git push origin feature/amazing-feature`) 5. Open a Pull Request ## ๐Ÿ“„ License MIT License - feel free to use this in your projects! ## ๐ŸŒŸ Support If you find this tool useful, please consider giving it a star on GitHub! --- Made with โค๏ธ for developers who love fun terminals