Skip to content
프로젝트

소개

Ask LLM directly from your terminal using a pure bash script

AI 및 머신러닝

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
기록 수집 중
in 15 days
기록 수집 중
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

ask.sh

Ask LLM directly from your terminal, and let the AI answer your terminal's output without leaving the terminal. Or generate shell commands you're not familiar with. A bash script will do the trick. You can even manually write plugins to let AI help you do more things.

Install

This script is written in bash, Simply download the script and add execution permissions, this script relies on curl and jq, make sure they are installed on your system!

Manual Install

curl https://raw.githubusercontent.com/TBXark/ask.sh/master/ask.sh > /usr/local/bin/ask
chmod +x /usr/local/bin/ask

Install by npm

npm install -g ask.sh

Supported LLMs

  • All OpenAI Compatible LLMs API

Configuration

Config File

ask set-config answer_language chinese
ask set-config api_key sk-xxxx
ask set-config api_model deepseek-chat
ask set-config api_endpoint https://api.deepseek.com/chat/completions
ask set-config timeout 60
ask set-config debug false

You can also edit ~/.config/ask.sh/config.json directly

Upgrading the OpenAI default

Without a configured model, the default OpenAI endpoint now uses gpt-6-luna. Existing model settings are not overwritten. If you use the default OpenAI endpoint and ask get-config api_model still shows gpt-5-nano, run ask set-config api_model gpt-6-luna after upgrading. If you manage the model only through your environment, update ASK_SH_API_MODEL instead. Use ask get-config api_endpoint to check which endpoint is active.

View Configuration

ask get-config api_key
ask get-config api_model
# View all available configuration keys
ask get-config

Environment Variables

If you don't want to use a configuration file, you can set the configuration via environment variables.

export ASK_SH_API_KEY=xxx
export ASK_SH_API_MODEL=xxx
export ASK_SH_API_ENDPOINT=xxx
export ASK_SH_ANSWER_LANGUAGE=xxx
export ASK_SH_TIMEOUT=60
export ASK_SH_DEBUG=false

Or you can change configuration file path by setting ASK_SH_CONFIG_FILE environment variable

export ASK_SH_CONFIG_FILE=/path/to/config.json
export ASK_SH_CONFIG_DIR=/path/to/config/dir

Usage

Basic Commands

Generate Shell commands based on questions:

ask "What was my last git commit message?"
# Output:
# git log -1 --pretty=%B

Using command output as context:

ifconfig -a | ask "My local IP"
# Output:
# Your local IP address is `192.168.31.200`

Debug Mode

Enable debug mode to see detailed request/response information:

ask --debug "How to list files?"
# Or set via environment
export ASK_SH_DEBUG=true
ask "How to list files?"

Configuration Management

# Set configuration
ask set-config api_key sk-xxxx
ask set-config timeout 30

# View configuration
ask get-config api_key
ask get-config timeout

# View help
ask --help
ask --version

Plugins

Plugin Management

# Install a plugin
ask install-plugin https://raw.githubusercontent.com/TBXark/ask.sh/master/plugins/translate.sh

# List installed plugins  
ask list-plugins

# Use a plugin
ask -p translate "你好,世界" english
echo "Hello, World" | ask -p translate chinese

Install Plugin

ask install-plugin https://raw.githubusercontent.com/TBXark/ask.sh/master/plugins/translate.sh

Or you can install the plugin manually in the ~/.config/ask.sh/plugins directory

Use Plugin

Usage: ask -p PLUGIN_NAME [ARGS] or pipe | ask -p PLUGIN_NAME [ARGS]

echo "你好,世界" | ask -p translate english
# Output:
# Hello, World

Create Plugin

The plugin is a script file that implements the gen_content (required) and after_ask (optional) functions. The gen_content function is used to generate the context of the question, and the after_ask function is used to process AI's response.

In after_ask, you can do many things, such as writing the result to a file or directly executing the command returned by AI.

For details, please refer to example

Command Reference

Basic Usage

ask "your question"                    # Ask a question
command | ask "explain this output"   # Use command output as context
ask --debug "question"                # Enable debug mode
ask --help                            # Show help
ask --version                         # Show version

Configuration Commands

ask set-config <key> <value>          # Set configuration value
ask get-config <key>                  # Get configuration value

Available configuration keys:

  • api_key - API key for LLM service
  • api_model - Model name (defaults to gpt-6-luna for the default OpenAI endpoint; other endpoints retain the previous fallback)
  • api_endpoint - API endpoint URL (default: OpenAI API)
  • answer_language - Response language (default: english)
  • timeout - Request timeout in seconds (default: 60)
  • debug - Enable debug mode (default: false)

Plugin Commands

ask install-plugin <url>              # Install plugin from URL
ask list-plugins                      # List installed plugins
ask -p <plugin_name> [args]           # Use a plugin

Environment Variables

All configuration can be overridden using environment variables:

  • ASK_SH_API_KEY
  • ASK_SH_API_MODEL
  • ASK_SH_API_ENDPOINT
  • ASK_SH_ANSWER_LANGUAGE
  • ASK_SH_TIMEOUT
  • ASK_SH_DEBUG
  • ASK_SH_CONFIG_FILE - Custom config file path
  • ASK_SH_CONFIG_DIR - Custom config directory path

Thanks

This project was inspired by the egoist/shell-ask project, but since it has a dependency on nodejs, I decided to rewrite it in bash

License

ask.sh is released under the MIT license. See LICENSE for details.

관련 프로젝트 살펴보기

불러오는 중…