: ' abc - AI bash/zsh/tcsh Command

abc

AI Bash Command*with support for bash, zsh, tcsh

What is abc?

abc is a command line tool that converts natural language instructions into shell commands using LLM models like Claude 3.5 Sonnet from Anthropic.

abc places the generated command on the next shell prompt, making it easy to review and edit before running withEnterorReturn

$ abc list files one per line, sorting lines from short to long

# may generate something like:
$ ls -1 | awk '{ print length, $0 }' | sort -n | cut -d" " -f2-

Key Features

  • Translates natural language into bash/zsh/tcsh commands
  • Interactive to review and edit before execution
  • Seamless integration with existing shell prompt
  • abc (natural language) command is added to shell history
  • Generated command is added to shell history, if it is run
  • Direct communication with LLM APIs using your own credentials
  • Multiple LLM providers supported (including Anthropic Claude, AWS Bedrock)
  • Plugin system for easy addition of new LLM providers
  • Provider/model selection via command line and config file
  • Includes awareness of current shell and operating system
  • Evaluates and warns about potentially dangerous commands

Prerequisites

  • Linux or macOS
  • bash 4.4+, zsh 5.0+, or tcsh 6.0+
  • Python 3.8 or higher
  • An Anthropic API key, or AWS credentials for AWS Bedrock

Quick Install

Install the latest version of abc from GitHub using pipx

curl -fsSL https://getabc.sh/ | bash

Reload your shell rc file to enable abc command

# For bash:
source ~/.bashrc

# For zsh:
source ~/.zshrc

# For tcsh:
source ~/.tcshrc

Verify abc Installation

abc hi
abc --version

More Information

For more details, manual installation options, upgrade, uninstall, and troubleshooting, see the complete installation guide.

Examples

Get current date in ISO format

$ abc current date/time to minute in ISO 8601, but with a space
$ date '+%Y-%m-%d %H:%M'

Find duplicate files

$ abc find duplicate files. separate groups by blank line
$ find . -type f -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate | cut -c 35-

AWS CLI example

$ abc List my EC2 instances: id, Name, type, start time
$ aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId,Tags[?Key==`Name`].Value | [0],InstanceType,LaunchTime]' --output table

Safety Features

abc uses the LLM to evaluate the potential danger of each generated command using a risk scale:

  • Level 0: Read only, informational command
  • Level 1: Modifies the system in common ways or generates some standard side effects
  • Level 2: Potential loss of significant data or large side effects

Commands the LLM evaluates with Level 2 risk are prefixed with a #DANGEROUS# comment, which requires removal before execution. A brief justification is provided for its evaluation, helping the user understand the potential risk.

Caveats & Warnings

  • Commands should ALWAYS be reviewed carefully before execution
  • AI LLMs may not generate correct, expected, or desired results
  • Risk level evaluation is not foolproof
  • Results may vary between runs, even with identical input
  • Commercial LLM API usage has associated costs

Security & Privacy

  • abc communicates directly with the user's chosen AI LLM API provider (e.g., Anthropic)
  • abc uses the LLM provider API key provided by the user
  • Users are responsible for securing their API key in the $HOME/abc.conf file
  • Review the LLM provider's privacy policy for data handling practices

LLM API Providers

Credits & License

  • Written by Anthropic Claude 3.5 Sonnet
  • Prompt crafting by Eric Hammond
  • Apache 2 License (see LICENSE file)
  • Current version: 2024.12.30