Skip to content

cbwinslow/cbwsh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

cbwsh - Custom Bubble Tea Shell

A modern, modular terminal shell built with the complete Bubble Tea ecosystem. Features rich TUI components, animations, syntax highlighting, AI integration, visual effects, and more.

Features

Core Shell Features

  • 🐚 Multi-shell support: Execute bash and zsh commands
  • πŸ“Š Multiple panes: Split terminal with different layouts (single, horizontal, vertical, grid)
  • πŸ”Œ Plugin system: Extensible architecture with command, UI, hook, and formatter plugins
  • ⌨️ Autocompletion: Smart command, file, environment variable, and history completion

Security & Secrets

  • πŸ” Secrets manager: Encrypted storage using AES-256-GCM with Argon2id key derivation
  • πŸ”‘ Multi-backend encryption: Support for AES, age, and GPG encryption
  • πŸ“‚ Git integration: Sync secrets with git or yadm (Yet Another Dotfiles Manager)
  • πŸ”’ API key management: Specialized management for API keys

AI Integration

  • πŸ€– AI agents: Integrated AI agents for command suggestions, explanations, and error fixes
  • 🌐 Multiple providers: Support for OpenAI, Anthropic, Gemini, and local LLMs
  • πŸ—£οΈ A2A Protocol: Agent-to-agent communication for building complex AI workflows
  • πŸ’¬ AI Chat Pane: Resizable, configurable chat interface for AI conversations
  • πŸ“ Markdown rendering: AI responses rendered with full markdown support

SSH & Remote

  • πŸ“‘ SSH manager: Manage and connect to SSH hosts with key/password authentication
  • πŸ”— Port forwarding: Local port forwarding support
  • πŸ“‹ Host management: Save and recall SSH host configurations

UI Components

  • πŸ“ˆ Progress bars: Beautiful progress indicators using Bubble Tea
  • πŸ“ Markdown editor: Edit markdown files with live preview
  • ✨ Visual effects: Water waves, fluid dynamics, and particle systems using harmonica
  • 🎨 Syntax highlighting: Shell command highlighting with chroma
  • 🎭 Themes: Multiple color themes (default, dracula, nord)

Terminal Features

  • πŸ“‹ Menu bar: Standard File, Edit, View, Help menus with keyboard shortcuts
  • πŸ“ Command history: Persistent history with search
  • βš™οΈ Job control: Background job management (start, stop, resume, kill)
  • πŸ“Š Logging: Structured logging with multiple levels and formats
  • πŸ”‘ Privilege management: Sudo/su integration and privilege elevation
  • πŸ–₯️ POSIX signals: Signal handling and process management

Architecture

The project follows a modular architecture with complete abstraction:

cbwsh/
β”œβ”€β”€ cmd/cbwsh/          # Main entry point
β”œβ”€β”€ internal/app/       # Main application logic
└── pkg/
    β”œβ”€β”€ core/           # Core types, interfaces, and enums
    β”œβ”€β”€ config/         # Configuration management
    β”œβ”€β”€ shell/          # Shell executor (bash/zsh)
    β”œβ”€β”€ panes/          # Pane/layout management
    β”œβ”€β”€ plugins/        # Plugin system
    β”œβ”€β”€ secrets/        # Encrypted secrets storage (AES, age, GPG)
    β”œβ”€β”€ ssh/            # SSH connection management
    β”œβ”€β”€ ai/             # AI agents, A2A protocol, and tools
    β”œβ”€β”€ logging/        # Structured logging infrastructure
    β”œβ”€β”€ process/        # Job control and process management
    β”œβ”€β”€ privileges/     # Privilege checking and elevation
    β”œβ”€β”€ posix/          # POSIX signals and system calls
    └── ui/
        β”œβ”€β”€ menu/       # Menu bar component
        β”œβ”€β”€ progress/   # Progress bar component
        β”œβ”€β”€ markdown/   # Markdown renderer
        β”œβ”€β”€ animation/  # Harmonica animations
        β”œβ”€β”€ autocomplete/ # Autocompletion
        β”œβ”€β”€ highlight/  # Syntax highlighting
        β”œβ”€β”€ styles/     # UI styles and themes
        β”œβ”€β”€ effects/    # Visual effects (water, fluid, particles)
        β”œβ”€β”€ aichat/     # AI chat pane component
        └── editor/     # Markdown editor component

Dependencies

Built with the complete Charm ecosystem:

Key Bindings

Key Action
Ctrl+Q Quit
Ctrl+C Cancel current command
Enter Execute command
Tab Autocomplete
↑/↓ Navigate history
Ctrl+L Clear screen
Ctrl+N New pane
Ctrl+W Close pane
Ctrl+] Next pane
Ctrl+[ Previous pane
Ctrl+\ Split vertical
Ctrl+- Split horizontal
Ctrl+B Toggle sidebar
Ctrl+A AI assist mode
Ctrl+? Help

Menu Bar

Key Action
Alt+M / F10 Toggle menu bar
Alt+F File menu
Alt+E Edit menu
Alt+V View menu
Alt+H Help menu
←/β†’ Navigate menus
↑/↓ Navigate items
Enter Select item
Escape Close menu

AI Chat Pane

Key Action
Ctrl+Enter Send message
Ctrl+L Clear chat
Escape Unfocus pane
PageUp/PageDown Scroll chat

Markdown Editor

Key Action
Ctrl+S Save
Ctrl+P Toggle mode (edit/preview/split)
Ctrl+B Insert bold
Ctrl+I Insert italic
Ctrl+K Insert link
Ctrl+H Insert heading

Installation

Quick Install (Recommended)

Linux / macOS

curl -fsSL https://raw.githubusercontent.com/cbwinslow/cbwsh/main/install.sh | bash

Or with wget:

wget -qO- https://raw.githubusercontent.com/cbwinslow/cbwsh/main/install.sh | bash

Windows (PowerShell)

iwr https://raw.githubusercontent.com/cbwinslow/cbwsh/main/install.ps1 | iex

Or download and run manually:

.\install.ps1 -AddToPath

Using Go

go install github.com/cbwinslow/cbwsh@latest

Build from Source

git clone https://github.com/cbwinslow/cbwsh.git
cd cbwsh
make install

Or without make:

git clone https://github.com/cbwinslow/cbwsh.git
cd cbwsh
go build -o cbwsh .
./cbwsh

Installation Options

Linux/macOS Script Options

# Install specific version
curl -fsSL https://raw.githubusercontent.com/cbwinslow/cbwsh/main/install.sh | bash -s -- --version v1.0.0

# Install to custom location
curl -fsSL https://raw.githubusercontent.com/cbwinslow/cbwsh/main/install.sh | bash -s -- --prefix ~/.local/bin

# Install without sudo
curl -fsSL https://raw.githubusercontent.com/cbwinslow/cbwsh/main/install.sh | bash -s -- --no-sudo --prefix ~/.local/bin

Windows PowerShell Options

# Install specific version
.\install.ps1 -Version v1.0.0

# Install to custom location
.\install.ps1 -Prefix "C:\Tools\cbwsh"

# Install and add to PATH
.\install.ps1 -AddToPath

Makefile Targets

make                  # Build the binary
make install          # Install to /usr/local/bin
make install PREFIX=~/.local  # Install to custom prefix
make uninstall        # Remove installed binary
make test             # Run tests
make lint             # Run linter
make clean            # Clean build artifacts
make cross-compile    # Build for all platforms
make help             # Show all available targets

Configuration

Configuration is stored in ~/.cbwsh/config.yaml. Example:

shell:
  default_shell: bash
  history_size: 10000

ui:
  theme: default
  layout: single
  show_status_bar: true
  enable_animations: true
  syntax_highlighting: true

ai:
  provider: gemini  # Options: none, openai, anthropic, gemini, local
  api_key: ""       # Store in secrets manager for security
  model: "gemini-pro"
  enable_suggestions: true

secrets:
  store_path: ~/.cbwsh/secrets.enc
  encryption_algorithm: AES-256-GCM  # Options: AES-256-GCM, age, gpg
  key_derivation: argon2id

keybindings:
  quit: ctrl+q
  help: ctrl+?
  ai_assist: ctrl+a

Visual Effects

cbwsh includes several visual effects powered by harmonica physics:

Water Effect

water := effects.NewWaterEffect(width, height)
water.SetColors(effects.DefaultWaterColors)
water.Update()
output := water.RenderColored()

Fluid Simulation

fluid := effects.NewFluidSimulation(width, height, viscosity, diffusion)
fluid.AddDensity(x, y, amount)
fluid.AddVelocity(x, y, vx, vy)
fluid.Step()
output := fluid.RenderColored()

Particle System

particles := effects.NewParticleSystem(width, height, maxParticles)
particles.SetColors(effects.DefaultFireColors)
particles.Emit(x, y, count, spread, speed)
particles.Update()
output := particles.RenderColored()

Logging

import "github.com/cbwinslow/cbwsh/pkg/logging"

// Create a logger
logger := logging.New(
    logging.WithLevel(logging.LevelDebug),
    logging.WithOutput(os.Stderr),
)

// Log messages
logger.Info("Application started")
logger.Debug("Debug message")
logger.Error("Something went wrong")

// With fields
logger.WithField("user", "john").Info("User logged in")
logger.WithFields(map[string]any{
    "action": "execute",
    "command": "ls -la",
}).Debug("Command executed")

Job Control

import "github.com/cbwinslow/cbwsh/pkg/process"

// Create job manager
manager := process.NewJobManager(100)

// Start a background job
job, err := manager.StartJob(ctx, "sleep 10", "/bin/bash")

// List jobs
for _, job := range manager.ListJobs() {
    fmt.Printf("%s\n", job.String())
}

// Stop a job
manager.StopJob(job.ID)

// Continue a stopped job
manager.ContinueJob(job.ID)

// Kill a job
manager.KillJob(job.ID)

Privilege Management

import "github.com/cbwinslow/cbwsh/pkg/privileges"

// Create privilege manager
manager := privileges.NewManager()

// Check current privileges
if manager.IsRoot() {
    fmt.Println("Running as root")
}

// Check if command requires elevation
if privileges.RequiresElevation("apt update") {
    fmt.Println("Needs sudo")
}

// Execute elevated command
output, err := manager.ExecuteElevated(ctx, "apt update")

POSIX Signals

import "github.com/cbwinslow/cbwsh/pkg/posix"

// Create signal manager
manager := posix.NewSignalManager()

// Register signal handler
manager.RegisterHandler(posix.SIGINT, func(sig posix.Signal) {
    fmt.Printf("Received %s\n", sig)
})

// Start handling signals
manager.Start(posix.SIGINT, posix.SIGTERM)

// Send signal to process
posix.Send(pid, posix.SIGTERM)

AI Integration

Using AI Agents

// Create an AI agent
agent := ai.NewAgent("assistant", core.AIProviderGemini, apiKey, "gemini-pro")

// Query the agent
response, err := agent.Query(ctx, "How do I list files?")

// Get command suggestions
cmd, err := agent.SuggestCommand(ctx, "find large files")

// Explain a command
explanation, err := agent.ExplainCommand(ctx, "find . -size +100M")

A2A Protocol

// Create A2A router
router := ai.NewA2ARouter()

// Register agents
router.RegisterHandler("shell-assistant", ai.NewShellAssistant(agent))

// Send messages between agents
msg := &ai.A2AMessage{
    Type:    ai.A2AMessageTypeQuery,
    From:    "user",
    To:      "shell-assistant",
    Payload: "Suggest a command to compress files",
}
response, err := router.Send(ctx, msg)

Development

# Run tests
go test -v ./...

# Run linter
golangci-lint run ./...

# Build
go build -o cbwsh .

# Or use make
make test           # Run tests
make lint           # Run linter
make build          # Build binary
make dev            # Development mode with file watching

Roadmap

See TODO.md for a comprehensive list of planned features, including:

  • πŸ€– AI Features: Natural language commands, error fixes, code generation
  • πŸ–₯️ Terminal UI: Floating panes, tabs, themes, visual effects
  • 🐚 Shell Features: Block-based input, structured output, job progress
  • πŸ”’ Security: Password manager integrations, 2FA, hardware keys
  • πŸ“‘ SSH & Remote: Multi-hop connections, SFTP, Mosh support
  • 🎨 Customization: Starship-like prompts, custom themes, key bindings
  • πŸ”§ Integration: Git, Docker, Kubernetes, cloud providers

We welcome contributions! Check the TODO.md for areas where you can help.

License

MIT


Built with Bubble Tea and the Charm ecosystem

About

my own custom shell

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •