DEV Community

Cover image for Improving Tinybird DevEx 🚀 Creating an Informative CLI Prompt with Oh My Posh
Sebastian Zakłada
Sebastian Zakłada

Posted on

Improving Tinybird DevEx 🚀 Creating an Informative CLI Prompt with Oh My Posh

If you are working with Tinybird regularly, you know how important it is to stay aware of your current workspace and environment. Instead of running multiple commands to check these, wouldn't it be great to have this information right in your prompt?

In this guide, I'll help you to enhance your CLI experience by creating a custom Oh My Posh prompt that displays Tinybird-specific information.

Here is how your customized prompt will look once configured:

Oh My Posh final prompt

Shortcut: If Tinybird and Oh My Posh are not news to you, feel free to skip directly to here for information on how to add Tinybird to your existing prompt.

Tinybird? Never heard of it before!

Let me fix that for you right away! 😄

Tinybird is a real-time data platform that lets developers build SQL-based APIs for working with massive datasets. It builds on ClickHouse, which is widely recognized as one of the fastest analytical databases for real-time data processing workloads.

While traditional data warehouses like Redshift excel at batch analytics and BI workloads - think of them as freight trains hauling massive amounts of data - Tinybird is more like a high-speed maglev train, optimized for real-time, user-facing analytics that require instant responses.

Maglev Train

When building data products with Tinybird, you'll typically work across multiple contexts:

  • Different workspaces for various projects
  • Multiple environments (development, staging, production)
  • Distinct configurations and data pipelines per context

Managing these different contexts efficiently is crucial for a smooth development workflow. An informative CLI prompt becomes invaluable here - it helps you maintain awareness of your current workspace and environment without repeatedly running status-checking commands.

Why Customize Your Prompt?

As developers, we spend significant time in the terminal. When working with Tinybird, you need to:

  • Check which workspace you're in
  • Verify your current environment
  • Ensure you're using the right AWS account

How often have you run a tb command only to realize you were in the wrong workspace? Or deployed to production (I know, I know... it was "someone else" on the team... right? 😉) while your AWS credentials were pointing to a different account?

Having this information directly in your prompt eliminates these "oops" moments and helps prevent mistakes like accidentally pushing to the wrong workspace.

  • We'll set up Oh My Posh to display Tinybird information in your prompt
  • You'll see your current workspace, environment, and other helpful information at a glance
  • This works with bash, zsh, and PowerShell
  • The configuration is also fully customizable to your needs

Prerequisites

You'll need the following tools installed:

  • Tinybird CLI - configured and ready to use
  • Oh My Posh - for prompt customization
  • A terminal that supports Unicode characters like the one bundled with Visual Studio Code
  • Nerd Font - required for icons

Setting Up Oh My Posh

oh-my-posh

Before diving into Tinybird-specific customizations, let's set up Oh My Posh correctly. The installation process varies depending on your operating system.

Windows Installation

If you're using Windows, you have several installation options:

# Option 1: Using winget (Recommended)
winget install JanDeDobbeleer.OhMyPosh

# Option 2: Using Scoop
scoop install https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/oh-my-posh.json

# Option 3: Using Chocolatey
choco install oh-my-posh
Enter fullscreen mode Exit fullscreen mode

macOS Installation

For macOS users:

# Option 1: Using Homebrew (Recommended)
brew install jandedobbeleer/oh-my-posh/oh-my-posh

# Option 2: Using MacPorts
sudo port selfupdate
sudo port install oh-my-posh
Enter fullscreen mode Exit fullscreen mode

Linux Installation

For Linux systems:

# Option 1: Using curl (Universal)
curl -s https://ohmyposh.dev/install.sh | bash -s

# Option 2: Using homebrew
brew install jandedobbeleer/oh-my-posh/oh-my-posh
Enter fullscreen mode Exit fullscreen mode

For detailed installation instructions tailored to your specific setup and additional configuration options, consult the official documentation. The docs cover all platforms and special cases like WSL environments.

Understanding Nerd Fonts

Oh My Posh needs a Nerd Font to display icons correctly.

Nerd Fonts are modified versions of popular programming fonts that add a vast collection of icons (glyphs) to the original font. Think of them as regular programming fonts supercharged with extra symbols - like the Git branch icon, folder symbols 📂, or platform-specific icons.

Installation

Oh My Posh has a CLI to help you select and install a Nerd Font:

# To install the recommended font
oh-my-posh font install meslo

# For manual font selection
oh-my-posh font install
Enter fullscreen mode Exit fullscreen mode

After installing a Nerd Font, you'll need to configure your terminal to use it. The configuration process varies depending on your terminal emulator.

Remember that each terminal maintains its own font settings. Configuring VS Code integrated terminal will not affect your standalone terminal emulator, and vice versa. For detailed configuration steps for each terminal type, refer to the official Oh My Posh documentation.

Here's how to set it up in VS Code:

// settings.json
{
  "terminal.integrated.fontFamily": "MesloLGM Nerd Font",
  // Optional: enable font ligatures
  "terminal.integrated.fontLigatures": true
}
Enter fullscreen mode Exit fullscreen mode

Creating the Tinybird Prompt Segment

To display Tinybird workspace information in your prompt, we'll create a custom segment that integrates with Oh My Posh. This involves two steps:

  1. Creating a script to fetch Tinybird information
  2. Adding the segment to your Oh My Posh configuration

Step 1: Create the Tinybird Status Script

Create a new file called tb-prompt.sh in your .aws directory. On different systems, this will be:

  • Windows: C:\Users\YOUR_USERNAME\.aws\tb-prompt.sh
  • Mac/Linux: ~/.aws/tb-prompt.sh

Add the following content to the script:

if [ -e ".tinyb" ]; then        
    branch_name=`grep '"name":' .tinyb | cut -d : -f 2 | cut -d '"' -f 2`
    region=`grep '"host":' .tinyb | cut -d / -f 3 | cut -d . -f 2 | cut -d : -f 1`
    if [ "$region" = "tinybird" ]; then
        region=`grep '"host":' .tinyb | cut -d / -f 3 | cut -d . -f 1`
    fi    

    echo "tb:${branch_name}"
fi
Enter fullscreen mode Exit fullscreen mode

Make the script executable (Mac/Linux only):

chmod +x ~/.aws/tb-prompt.sh
Enter fullscreen mode Exit fullscreen mode

This script:

  • Checks for a .tinyb configuration file in the current directory
  • Extracts the branch name and region information
  • Outputs the branch name in the format tb:branch_name

Step 2: Configure Oh My Posh

Add the Tinybird segment to your Oh My Posh configuration by including this segment configuration:

{
  "type": "command",
  "style": "powerline",
  "powerline_symbol": "\ue0b0",
  "foreground": "#00b7ff",
  "background": "#193549",
  "properties": {
    "shell": "bash",
    "script": "~/.aws/tb-prompt.sh"
  },
  "template": " \uf1c0 {{ .Output }} "
}
Enter fullscreen mode Exit fullscreen mode

This configuration:

  • Runs the tb-prompt.sh script to get Tinybird information
  • Uses a database icon (\uf1c0) from Nerd Fonts
  • Displays the output in a clean format with distinctive colors
  • Integrates with the powerline style of the prompt

Note: The segment will only show Tinybird information when you're in a directory containing a .tinyb configuration file.

Let's look at a complete Oh My Posh configuration that combines some of the tools a developer may need:

  • AWS Profile & Region - shows your current AWS credentials context
  • Environment Stage - displays the current stage (like dev/prod)
  • Node.js Version - shows Node version and package manager
  • Current Path - displays your working directory
  • Git Status - shows branch, changes, stash count, and more
  • Tinybird Workspace - displays current Tinybird workspace (from our script)
  • NET Version - shows the .NET SDK version if applicable
  • Root Indicator - shows when you're running as administrator/root
  • Execution Time - displays how long the last command took
  • Exit Code - shows success/failure of the last command

Oh My Posh final prompt

Save this as ~/.ohmyposh.json (or your preferred config location) and customize the colors, symbols, and segments to match your preferences:

{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "blocks": [
    {
      "alignment": "left",
      "segments": [
        {
          "background": "#FFA400",
          "foreground": "#193549",
          "leading_diamond": "\ue0b6",
          "powerline_symbol": "\ue0b0",
          "style": "diamond",
          "template": " {{ .Profile }}{{ if .Region }}@{{ .Region }}{{ end }} ",
          "trailing_diamond": "\ue0b0",
          "type": "aws"
        },
        {
          "type": "text",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#ffffff",
          "background": "#f792c1",
          "template": "{{ if eq \"devtest\" .Env.STAGE }} {{ else }} \uf635 {{ .Env.STAGE }} {{ end }}"
        },
        {
          "type": "node",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#ffffff",
          "background": "#6CA35E",
          "template": "{{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}{{ .Full }} ",
          "properties": { "fetch_package_manager": true }
        },
        {
          "background": "#ff479c",
          "foreground": "#ffffff",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "style": "folder"
          },
          "style": "powerline",
          "template": " \ue5ff {{ .Path }} ",
          "type": "path"
        },
        {
          "background": "#fffb38",
          "foreground": "#193549",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "fetch_stash_count": true,
            "fetch_status": true,
            "fetch_upstream_icon": true
          },
          "style": "powerline",
          "template": " {{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if and (.Staging.Changed) (.Working.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0}} \uf692 {{ .StashCount }}{{ end }}{{ if gt .WorktreeCount 0}} \uf1bb {{ .WorktreeCount }}{{ end }} ",
          "type": "git"
        },
        {
          "type": "command",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#00b7ff",
          "background": "#193549",
          "properties": {
            "shell": "bash",
            "script": "~/.aws/tb-prompt.sh"
          },
          "template": " \uf1c0 {{ .Output }} "
        },
        {
          "background": "#6CA35E",
          "foreground": "#ffffff",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "fetch_version": true
          },
          "style": "powerline",
          "template": " \ue70c {{ if .Unsupported }}\uf071{{ else }}{{ .Full }}{{ end }} ",
          "type": "dotnet"
        },
        {
          "background": "#ffff66",
          "foreground": "#ffffff",
          "powerline_symbol": "\ue0b0",
          "style": "powerline",
          "template": " \uf0e7 ",
          "type": "root"
        },
        {
          "background": "#8800dd",
          "foreground": "#ffffff",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "style": "austin",
            "threshold": 500
          },
          "style": "powerline",
          "template": " <#fefefe>\ufbab</> {{ .FormattedMs }} ",
          "type": "executiontime"
        },
        {
          "background": "#2e9599",
          "background_templates": ["{{ if gt .Code 0 }}#f1184c{{ end }}"],
          "foreground": "#ffffff",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "always_enabled": true
          },
          "style": "powerline",
          "template": " {{ if gt .Code 0 }}\uf00d{{ else }}\uf42e{{ end }} ",
          "trailing_diamond": "\ue0b4",
          "type": "exit"
        }
      ],
      "type": "prompt"
    }
  ],
  "final_space": true,
  "version": 2
}
Enter fullscreen mode Exit fullscreen mode

The Impact of a Better Prompt

Configuring your command prompt goes beyond aesthetics - it's about developer productivity and safety. Having instant visibility into your workspace and environment status helps prevent common mistakes and speeds up your workflow.

It's about making your daily work smoother and safer.

Think of it as your development cockpit - just as pilots rely on their (super cool!) instruments, developers need clear visibility of their working context. This becomes especially crucial when working with multiple Tinybird workspaces and AWS environments.

With instant visibility into your workspace and environment status, you can confidently avoid those costly mistakes that happen when context isn't clear.

Where to Next?

This is just the beginning of improving your Tinybird development experience. In the upcoming articles, I will explore:

  • Tinybird Console Pro Tips - unlocking the full-width view and most importantly, the dark mode - vampires like me 🧛 fear the light!
  • IaC Blueprint - structuring your Tinybird projects like a pro
  • Multi-tenancy Guide - implementing secure and scalable multi-tenant analytics with Tinybird and AWS
  • Production Checklist - everything you need for truly production-ready analytics
  • Node.js SDK - Tinybird SDK for Node.js that you never knew you needed!
  • Data Re-population CLI Tool - for efficiently managing and reloading your datasets
  • and many more!

Stay tuned!

Note

This is my first technical writeup in quite a while (I usually write about craft beer, and in my native language at that!). I'd love to hear your thoughts, suggestions, or even gentle 😄 corrections - don't hesitate to drop a comment.

Your feedback, whether it's a nod of approval or pointing out areas for improvement, will help me craft better content in the future!

Disclaimer

This article is an independent developer guide. I am not affiliated with, sponsored by, or officially connected to Tinybird in any way. All views and recommendations expressed are my own.

While these customizations are generally safe, if your coding adventures somehow result in your workstation spontaneously combusting, I must respectfully decline any responsibility for damage to you or your property. However, as a courtesy to your friendly Engineering Vampire 🧛 please do give advance notice of any potential... mishaps. It would be terribly wasteful to let good blood 🩸 go to waste. Just saying!

Top comments (4)

Collapse
 
javi_santana_93adb2436ad5 profile image
Javi Santana

AWESOME!

Collapse
 
sebekz profile image
Sebastian Zakłada

Glad that you liked it! Stay tuned, there is more cool TB related content to come 😊🦇!

Collapse
 
april-tinybird profile image
April Schuppel

Great post! Love your style and the train analogy

Collapse
 
danielribes profile image
Daniel Ribes • Edited

Thank you for the post, interesting! However 👀 the link: "consult the official documentation" in Linux installation section ... doesn't work, it returns a 404.