Dashbrew Terminal Dashboard Builder

repository·master·Indexed 42 days ago

https://github.com/rasjonell/dashbrew

A terminal dashboard builder that visualizes data from scripts and APIs using a JSON configuration file. It supports various component types including text, charts, histograms, and todo lists, with customizable themes and keyboard-driven navigation.

Tokens
2K
Snippets
6
Records
8
Agent score
5%

What's inside Dashbrew

  1. Basic Navigation in Dashbrew

    master

    Use these keyboard shortcuts to navigate and interact with your dashboard:

    • Shift+Arrow or Shift + H/J/K/L: Move focus between components.
    • R: Refresh data for the currently focused component.
    • Ctrl+K: Open the action palette (fuzzy filterable list of all available bindings).
    • Ctrl+C: Quit Dashbrew.

    Todo List specific keys:

    • A: Add an item.
    • Space: Toggle item state.
  2. Quick Start with Dashbrew

    master

    Dashbrew uses a JSON configuration file to define the dashboard layout and components.

    1. Create a dashboard.json file with a layout and style configuration.
    2. Run the dashboard using the -c flag:
    dashbrew -c dashboard.json

    Example configuration:

    {
      "style": {
        "border": {
          "type": "thicc",
          "color": "#cccccc",
          "focusedColor": "#474747"
        }
      },
      "layout": {
        "type": "container",
        "direction": "row",
        "children": [
          {
            "type": "component",
            "flex": 1,
            "component": {
              "type": "text",
              "title": "Hello Dashbrew",
              "data": {
                "source": "script",
                "command": "echo 'Welcome to Dashbrew!'"
              }
            }
          }
        ]
      }
    }
    dashbrew -c dashboard.json
  3. Install Dashbrew

    master

    You can install Dashbrew using go install or by building from the source code.

    Using Go Install

    To install the latest version:

    go install github.com/rasjonell/dashbrew/cmd/dashbrew@latest

    To pin a specific version (e.g., v1.1.0):

    go install github.com/rasjonell/dashbrew/cmd/dashbrew@v1.1.0

    From Source

    Clone the repository and use go install on the command directory:

    git clone https://github.com/rasjonell/dashbrew.git
    cd dashbrew
    go install ./cmd/dashbrew
    go install github.com/rasjonell/dashbrew/cmd/dashbrew@latest
  4. Configure Dashboard Themes

    master

    Dashbrew supports several built-in themes: default, dracula, nord, gruvbox-dark, tokyo-night, catppuccin-mocha, and solarized-light.

    Using Built-in Themes

    Set the theme in your JSON config:

    { "style": { "theme": "dracula" } }

    Or set it to "auto" to detect the terminal background color via OSC 11.

    Overriding at Runtime

    You can override the theme via the CLI without editing the config file:

    dashbrew -c dashboard.json -t nord

    Use dashbrew --list-themes to see available options.

    Custom Themes

    Custom themes can be added by placing JSON files in $XDG_CONFIG_HOME/dashbrew/themes/ (or by setting the DASHBREW_THEMES_DIR environment variable). A theme file must define a name and a palette containing role colors: background, foreground, dim, accent, success, warning, error, border, and borderFocused.

    dashbrew -c dashboard.json -t nord
  5. Configure Component Bindings and Actions

    master

    Components can define bindings to map keys to shell actions. This allows you to trigger commands directly from the dashboard.

    Action Types

    • fire_and_forget: Runs a command in the background. The pane remains unchanged. Useful for triggering external apps or clearing logs.
    • replace_pane: Runs a command and replaces the current pane's content with the command's stdout.
      • While a replace_pane result is active, scheduled refreshes are paused.
      • Press R to resume the original data schedule.
      • Press Esc to clear the action state without refetching.

    Output Rendering for replace_pane

    • output_as: "text" (default): Shows raw scrollable text.
    • output_as: "inherit": Parses stdout using the focused component's existing parser (e.g., a chart expects newline-separated numbers).

    Example Binding Configuration

    {
      "type": "component",
      "component": {
        "id": "logs",
        "type": "text",
        "title": "📜 Logs",
        "data": { "source": "script", "command": "tail -n 50 ./app.log", "refresh_interval": 5 },
        "bindings": [
          {
            "key": "f",
            "label": "Show last 500 lines",
            "action": {
              "type": "replace_pane",
              "command": "tail -n 500 ./app.log",
              "output_as": "text"
            }
          },
          {
            "key": "c",
            "label": "Clear log file",
            "action": { "type": "fire_and_forget", "command": ": > ./app.log" }
          }
        ]
      }
    }

    Note: Actions can include a timeout_seconds (default 30). Long-running stream commands like tail -f are not supported; use snapshots like tail -n 500 instead.

    {
      "type": "component",
      "component": {
        "id": "logs",
        "type": "text",
        "title": "📜 Logs",
        "data": { "source": "script", "command": "tail -n 50 ./app.log", "refresh_interval": 5 },
        "bindings": [
          {
            "key": "f",
            "label": "Show last 500 lines",
            "action": {
              "type": "replace_pane",
              "command": "tail -n 500 ./app.log",
              "output_as": "text"
            }
          }
        ]
      }
    }
  6. Component Data Sources and Types

    master

    Dashbrew components visualize data using different source types and type definitions.

    Common Component Types and Data Sources

    Text Component (API Data)

    Displays real-time data from a URL.

    {
      "type": "component",
      "component": {
        "type": "text",
        "title": "🌦️ Weather",
        "data": {
          "source": "api",
          "url": "https://wttr.in/<YOUR_CITY>?format=4",
          "refresh_interval": 60
        }
      }
    }

    Todo List (File Data)

    Displays a list from a local text file.

    {
      "type": "component",
      "component": {
        "type": "todo",
        "title": "📋 My Todo List",
        "data": {
          "source": "./todo.txt"
        }
      }
    }

    Chart (Script Data)

    Visualizes numeric data from a script command.

    {
      "type": "component",
      "component": {
        "type": "chart",
        "title": "📊 System Metrics",
        "data": {
          "source": "script",
          "command": "echo '10\n25\n15\n30\n45'",
          "refresh_interval": 5,
          "caption": "CPU Usage (%)"
        }
      }
    }

    Histogram (Script Data)

    Shows distributions using key: count lines or a JSON object.

    {
      "type": "component",
      "component": {
        "type": "histogram",
        "title": "📊 Age Distribution",
        "data": {
          "source": "script",
          "command": "echo '"18-24": 45\n"25-34": 78\n"35-44": 52\n"45-54": 34\n"55+": 21'",
          "caption": "Users by Age Group"
        }
      }
    }
  7. Reference dashbrew CLI flags

    master

    The following flags are available when running the dashbrew command:

    FlagAliasDescription
    -cN/APath to dashboard config. (Default: dashboard.json)
    -t--themeOverride style.theme from the config (e.g. dracula, nord).
    --list-themesN/AList available themes and exit.
    -c string
      Path to dashboard config. (default "dashboard.json")
    -t, --theme string
      Override style.theme from the config (e.g. dracula, nord).
    --list-themes
      List available themes and exit.
  8. Use the dashbrew CLI

    master

    Dashbrew is a terminal dashboard driven by a JSON configuration file. You can run it by providing a path to your configuration, overriding the visual theme, or listing available themes. By default, it looks for a dashboard.json file in the current directory.

    To run the dashboard with a specific configuration file:

    dashbrew -c my-config.json

    To override the theme defined in your configuration (e.g., using dracula or nord):

    dashbrew --theme dracula
    # Run with default dashboard.json
    dashbrew
    
    # Run with custom config path
    dashbrew -c /path/to/config.json
    
    # Run with a specific theme override
    dashbrew --theme nord