Anas's CLI Toolkit Wiki

Hmph. All the information you could possibly need, laid out for your convenience. Don't expect me to hold your hand, though.

Introduction

This is a collection of command-line utilities designed to make your daily Linux workflow a bit less... tedious. It's not like I built these because I enjoy helping, but someone had to do it. You'll find tools for quick AI assistance, automatic command fixing, and even a way to block those pesky distracting websites.

Installation

Getting these tools set up is quite simple. Just follow these steps. Don't mess it up.

  1. Clone the Repository:
    git clone https://github.com/anas1412/scripts.git
    cd scripts
  2. Run the Installer:

    The installer handles dependencies, copies scripts to ~/scripts/, and configures your shell.

    chmod +x install
    ./install

    Note: The script will prompt you for your Google Gemini API key. Ensure you have Python3 and pip3 installed; the installer will attempt to install the necessary Python library (`google-generativeai`) for your user.

  3. Activate Changes:

    After installation, refresh your shell to load the new commands and configurations.

    source ~/.zshrc # If you use Zsh
    # OR
    source ~/.bashrc # If you use Bash
    # OR simply close and reopen your terminal window.

ai Command

Purpose

The ai command allows you to quickly query an AI assistant for Linux-related questions. It provides a brief explanation and the most relevant command.

Usage

Simply type ai followed by your question in quotes.

ai "how do I recursively copy files and keep their permissions"
# Expected output example:
# To recursively copy files and preserve permissions, use 'cp -a'.
# cp -a source_directory/ destination_directory/

Details

fix Command

Purpose

Did your last command fail? Instead of re-typing, just use fix. This command analyzes the error output of your previous command and uses AI to suggest a corrected version, giving you an option to execute it immediately.

Usage

Run a command that you expect to fail (or one that just did), then type fix.

# Example: A typo in a common command
sudo apt updatee
# Output from apt:
# E: Invalid operation updatee
# E: Failed to fetch some archives, maybe run apt-get update or try with --fix-missing?

# Now, type 'fix':
fix
# Expected interaction:
# Attempting to re-run: sudo apt updatee
# The previous command failed (exit code 100).
# Sending details to AI for a suggested fix...
#
# AI suggests:
# sudo apt update
# Execute suggested command? (y/N): y
# # If you type 'y', 'sudo apt update' will then be executed.

Details

blocker Script

Purpose

The blocker script helps you easily manage entries in your /etc/hosts file to block specific websites. Useful for focus, or just... being picky about what you access.

Usage

The script uses actions (add, remove, edit, list) followed by domain names.

Add Domains

blocker add facebook.com twitter.com
# Adds 127.0.0.1 entries for facebook.com, www.facebook.com, twitter.com, www.twitter.com

List Blocked Domains

blocker list
# Displays the domains currently managed by the blocker script in /etc/hosts

Remove Domains

blocker remove facebook.com

Edit a Domain

blocker edit oldsite.com newsite.com
# Replaces oldsite.com (and its www. version) with newsite.com (and its www. version)

Get Help

blocker help
# Displays usage instructions

Details

install Script

Purpose

This script orchestrates the entire setup of Anas's CLI Toolkit. It's the first thing you run to get everything working.

Usage

Run from the root of the cloned repository:

chmod +x install
./install

Details

shell_config.sh

Purpose

This file acts as a centralized location for the custom shell aliases and functions provided by this toolkit (specifically ai and fix). It keeps your main .bashrc or .zshrc files cleaner.

Usage

This file is not meant to be run directly by the user. It is automatically:

  1. Created and populated by the install script during setup.
  2. Sourced (loaded) by your .bashrc or .zshrc every time you open a new terminal session. This makes the ai alias and fix function available.

Details