FM - now with previews and editor support
My file manager is coming along nicely. I am getting more comfortable with bubbletea and lipgloss. This means (aside from fixing one or two smaller bugs) I can start adding useful features and start refactoring the code a bit. I am not a big fan of putting everything into one 500 line Update method, so pulling apart ever growing functions was number one on the todo list.
I was going back and forth if I should add two different structures, one for a regular directory list and one for previews or if I put everything in a Pane view and simply add different render methods. Splitting the whole thing into multiple structures would have been a bit cleaner, but also means more type casting when getting the active view and figuring out how to react to input. Good enough for now, but something I might revisit if there is another "pane type".

Rendering the preview pane for text is not too involved.
header := lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color("205")).
Render(filepath.Base(pane.Path))
content = lipgloss.JoinVertical(
lipgloss.Left,
header,
"\n",
pane.Viewport.View(),
)
That is if you ignore the code handling the syntax highlighting during pane creation. I assume image rendering will not be a lot more complex as it mostly will be calling a library implementing the relevant correct protocols.
The other feature I really wanted to have in for daily use is opening a file or directory in an editor. I try to keep the shell and the file manager portable, so I try to honor $EDITOR if set, otherwise I fall back to vi. If even vi is not on the system I have no business editing files on it.
I have to say bubbletea makes it really simple to run a process and pass any potential errors back when returning.
type editFinishedMsg struct {
err error
}
func openInEditorCmd(path string) tea.Cmd {
editor := os.Getenv("EDITOR")
if editor == "" {
editor = "vi"
}
c := exec.Command(editor, path)
return tea.ExecProcess(c, func(err error) tea.Msg {
return editFinishedMsg{err}
})
}
Overall bubbletea looked a little bit off putting when I started using it, but once I had the basic concepts down and started refactoring some of the code it clicked. I could actually see myself writing more TUIs using it.
The other part that might be interesting to some of you - at least to the three people who asked - I added cmd/fm/fm.go. You can build and run the file manager standalone. I would discourage you from doing so right now, but with next weeks bug fixes it will be in a good enough shape to daily drive for basic file operations.
Progress
I started planning the digital frame to run my personal assistant on. It will either be the most ugly piece of wood framing a TV you have ever seen or it will look pretty decent. On paper the idea is pretty good. The infrared frame for 10 finger touch input works as expected. The foil to turn the glossy into into a matte display is sitting in a corner waiting for someone with patience, skill and small hands (read: my wife) to put it on the TV.
posted on Aug. 2, 2026, 7:42 p.m. in golang, lazerbunny