__ _ ____
/ / (_)_ __ ___/ ___| ___ _ __ ___ ___
/ / | | '_ \ / _ \___ \ / _ \ '_ \/ __|/ _ \
/ /___ | | | | | __/___) | __/ | | \__ \ __/
\____/ |_|_| |_|\___|____/ \___|_| |_|___/\___|
AI-Powered Shell Assistant (v0.6.6)
LineSense is an intelligent shell assistant that provides context-aware command suggestions and explanations. It integrates seamlessly with bash and zsh, learning from your usage patterns.
- ๐ฏ OS-Aware Suggestions (NEW in v0.5.2): Automatically detects your OS, distribution, and package manager
- Get
brew installon macOS,apt installon Ubuntu,pacman -Son Arch - Smart command suggestions tailored to your system
- Zero configuration required
- Get
- ๐จ Beautiful Terminal UI: Styled output with colors, borders, and dynamic width adjustment
- ๐ Dual Output Modes: Pretty format for humans, JSON for scripting (
--formatflag) - ๐ Global Instructions: Define personal rules that apply everywhere (e.g., "Always use bat")
- ๐ Project Context: Add
.linesense_contextfiles for directory-specific AI knowledge - โก Loading Indicators: Animated spinner while AI processes your request
- ๐ง Context-Aware Suggestions: Uses git info, shell history, environment, and OS context
- ๐ก๏ธ Safety First: Risk classification and configurable denylists
- ๐ Multi-Shell Support: Works with bash and zsh
- ๐ OpenRouter Integration: Powered by state-of-the-art LLMs via OpenRouter
- ๐ Responsive Design: Output automatically adapts to terminal width
- ๐ก Smart Explanations: Each suggestion includes a brief 5-10 word explanation
- ๐ข Multiple Suggestions: Get 3-5 alternative command options for every request
.
โโโ cmd/
โ โโโ linesense/ # Main CLI binary
โ โโโ main.go # CLI entry point
โ โโโ ui.go # Terminal UI (Lipgloss/Bubbletea)
โโโ internal/
โ โโโ config/ # Configuration loading
โ โ โโโ config.go # Global config
โ โ โโโ providers.go # Provider/model config
โ โโโ core/ # Core engine
โ โ โโโ context.go # Context gathering
โ โ โโโ engine.go # Main suggest/explain engine
โ โ โโโ git.go # Git integration
โ โ โโโ history.go # Shell history
โ โ โโโ osdetect.go # OS & package manager detection
โ โ โโโ safety.go # Safety filters
โ โ โโโ usage.go # Usage logging
โ โโโ ai/ # AI provider implementations
โ โโโ provider.go # Provider factory
โ โโโ prompts.go # AI prompts & parsing
โ โโโ openrouter.go # OpenRouter implementation
โโโ scripts/
โ โโโ linesense.bash # Bash integration
โ โโโ linesense.zsh # Zsh integration
โโโ examples/
โ โโโ config.toml # Example global config
โ โโโ providers.toml # Example providers config
โโโ docs/ # Comprehensive documentation
โ โโโ INSTALLATION.md # Installation guide
โ โโโ CONFIGURATION.md # Configuration reference
โ โโโ SECURITY.md # Security features
โ โโโ API.md # CLI reference
โ โโโ TESTING.md # Testing guide
โ โโโ CI_CD.md # CI/CD and release process
โโโ docs/ # Documentation (including PRD)
The easiest way to install LineSense is using the automated installation script:
# Download and run the installer
curl -fsSL https://raw.githubusercontent.com/traves-theberge/LineSense/main/install.sh | bashThis will:
- โ Build and install LineSense
- โ Set up shell integration (bash/zsh)
- โ Initialize configuration
- โ Guide you through API key setup
Then restart your shell and set your API key:
# Restart your shell or reload config
source ~/.bashrc # or ~/.zshrc
# Set your OpenRouter API key (interactive)
linesense config set-keyIf you prefer to install manually or want more control:
- Go 1.21 or later
- Git
- An OpenRouter API key (get one at https://openrouter.ai)
# 1. Clone the repository
git clone https://github.com/Traves-Theberge/LineSense.git
cd LineSense
# 2. Build and install
go install ./cmd/linesense
# 3. Initialize configuration
linesense config init
# 4. Set your OpenRouter API key
linesense config set-key
# 5. Set up shell integration
# For bash, add to ~/.bashrc:
echo '[ -f "$HOME/.config/linesense/shell/linesense.bash" ] && source "$HOME/.config/linesense/shell/linesense.bash"' >> ~/.bashrc
# For zsh, add to ~/.zshrc:
echo '[ -f "$HOME/.config/linesense/shell/linesense.zsh" ] && source "$HOME/.config/linesense/shell/linesense.zsh"' >> ~/.zshrc
# 6. Reload your shell
source ~/.bashrc # or ~/.zshrcInstall directly from the repository:
go install github.com/Traves-Theberge/LineSense/cmd/linesense@latest
linesense config init
linesense config set-key# Check version
linesense --version
# View configuration
linesense config show
# Try it out!
linesense suggest --line "list files sorted by size"
linesense explain --line "docker ps -a"LineSense provides two main commands:
Generate command suggestions based on natural language input:
# Pretty output (default) - beautiful terminal UI
linesense suggest --line "list files"
# JSON output for scripting
linesense suggest --line "list files" --format json
# Advanced options
linesense suggest --line "find large files" --cwd /var/log
linesense suggest --line "git com" --model openai/gpt-4oPretty Output (default):
๐ก Command Suggestions
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
1. ls -lhS
โ Risk: low
List files sorted by size in human-readable format
2. find . -type f -exec du -h {} + | sort -rh | head -20
โ Risk: low
Find and display 20 largest files
3. du -ah . | sort -rh | head -20
โ Risk: low
Show disk usage sorted by size
OS-Aware Examples:
Ubuntu user types "install nginx":
1. sudo apt install nginx
โ Risk: medium
Install nginx web server using apt
2. sudo apt install nginx-full
โ Risk: medium
Install nginx with all available modules
macOS user types "install nginx":
1. brew install nginx
โ Risk: low
Install nginx web server using Homebrew
2. brew install nginx --with-pcre
โ Risk: low
Install nginx with PCRE support
JSON Output (--format json):
{
"suggestions": [
{
"command": "ls -al",
"risk": "low",
"explanation": "Suggested based on: list files",
"source": "llm"
}
]
}Get detailed explanations of commands:
# Pretty output (default) - beautiful terminal UI
linesense explain --line "docker ps -a"
# JSON output for scripting
linesense explain --line "docker ps -a" --format jsonPretty Output (default):
๐ Command Explanation
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ Summary โ
โ โ
โ Lists all Docker containers (running and stopped) with their details โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ โ Risk Level: low โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
Details
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ What it does โ
โ - Shows container ID, image, command, status, ports, and names โ
โ - The -a flag includes stopped containers โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
JSON Output (--format json):
{
"summary": "Lists all Docker containers (running and stopped)...",
"risk": "low",
"notes": [
"What it does",
"- Shows container ID, image, command..."
]
}LineSense provides interactive shell integration for both bash and zsh. The integration loads silently in the background - no startup messages or notifications.
Default Keybindings:
- Press
Ctrl+Spaceto get AI-powered command suggestions - Press
Ctrl+Xto get an explanation of the current command
Customization: You can customize keybindings by setting environment variables before sourcing the script:
# In your ~/.bashrc or ~/.zshrc
export LINESENSE_SUGGEST_KEY="\C-t" # Change suggest to Ctrl+T
export LINESENSE_EXPLAIN_KEY="\C-x\C-h" # Change explain to Ctrl+X Ctrl+H
source ~/.config/linesense/shell/linesense.bashFeatures:
- ๐ก Smart suggestions - handles typos and provides intent-based alternatives
- ๐ Detailed explanations - comprehensive command breakdowns with risk assessment
- ๐ง Context-aware - uses current directory, git status, and shell history
- ๐ฅ๏ธ OS-aware - detects your operating system, distribution, and package manager for tailored suggestions
LineSense uses a TOML configuration file located at ~/.config/linesense/config.toml.
You can define global rules that the AI should always follow. This is useful for enforcing personal preferences or tools.
To edit your configuration, run:
linesense config editThen add your instructions to the [context] section:
[context]
global_instructions = """
- Always prefer 'bat' over 'cat'
- Use 'podman' instead of 'docker'
- When suggesting git commands, always include '--verbose'
"""For project-specific rules, create a .linesense_context file in your project's root directory. LineSense will automatically read this file when you are working in that directory.
You can easily create this file using the CLI:
linesense config init-projectExample .linesense_context:
This project uses a custom CLI tool called 'ops-cli'.
- To build: ops-cli build --env=prod
- To deploy: ops-cli deploy --region=us-east-1
- Never use 'kubectl' directly, always use 'ops-cli k8s' wrapper.