Athreya aka Maneshwar Posted on May 31 peektea: brewing a terminal file browser with Bubble Tea # programming # beginners # go # webdev Hello, I'm Maneshwar. I'm building git-lrc, a Micro AI code reviewer that runs on every commit. It is free and source-available on Github. Star git-lrc to help devs discover the project. Do give it a try and share your feedback for improving the project. What I actually want is an ncdu -style file browser fully keyboard-driven, where I can hop through directories and open files straight into Nautilus, vim, Nemo, whatever, even preview images right in the terminal. No mouse, no leaving the keyboard. But that's a big pot to brew. So I started small and used it as an excuse to learn Bubble Tea , Charmbracelet's Go TUI framework. The result is peektea : a minimal version that, for now, just browses . Run it, arrow your way through directories, pop back up to the parent. That's the whole cup of tea so far. ~140 lines of Go: the opening-files-and-previewing-images part is where it's headed next. So what's Bubble Tea? Bubble Tea is a Go framework for building terminal UIs, built on the Elm Architecture . Which is a fancy way of saying your entire app boils down to three things: Model — the state of your program Update — a function that takes events and returns a new model View — a function that renders the model to a string No mutation, no spilled state. Update and View are pure functions. The framework handles the event loop, terminal I/O, and all the redrawing so you don't have to. You just describe what things should look like and it does the dishes. The model type model struct { dir string entries [] os . DirEntry cursor int err error } Enter fullscreen mode Exit fullscreen mode That's the entire state of peektea. The current directory, what's in it, where the cursor sits, and whether something went sideways. When you navigate into a new directory you don't mutate anything in place, Update hands back
Back to Home

peektea: brewing a terminal file browser with Bubble Tea
B
Blizine Admin
·2 min read·0 views
📰Dev.to — dev.to
B
Blizine Admin
View Profile Staff Writer