Build an interactive terminal file browser using Bubble Tea. Applies concepts from Module 8.
Build an interactive file browser:
bubbles/list — for the file listlipgloss — for stylingos.ReadDir — for directory contentstype model struct {
currentDir string
files []os.DirEntry
cursor int
selected string
err error
}
func (m model) Init() tea.Cmd {
return loadDir(m.currentDir)
}
func loadDir(path string) tea.Cmd {
return func() tea.Msg {
entries, err := os.ReadDir(path)
if err != nil {
return errMsg{err}
}
return dirLoadedMsg{entries}
}
}
Skills Used: Bubble Tea architecture, lipgloss styling, file system operations, keyboard handling.