github charmbracelet/bubbletea v0.21.0

latest releases: v2.0.0-alpha.2, v1.2.2, v1.2.1...
2 years ago

Spawn Interactive Processes + More Keybindings

Finally! This update allows you to run blocking, interactive processes from Bubble Tea like vim, htop, curl, and even entire shells like fish. It also adds a bunch of new keybindings. Read on for more!

Let’s Exec

As we were saying, you can now spawn interactive processes in the terminal from Bubble Tea and resume Bubble Tea when they exit. For example, you could have your Bubble Tea program spawn vim to edit a file, or temporarily open a shell, like fish. Here’s what it looks like:

type editorFinishedMsg struct{ err error }

func openInVim(path string) tea.Cmd {
	c := exec.Command("vim", path)
	return tea.ExecProcess(c, func(err error) tea.Msg {
		return editorFinishedMsg{err}
	})
}

See the full example for details.

Keys Galore

Prior to this update, you couldn't bind to the functions keys. Isn't that crazy? @mrusme certainly thought so. With this update you can can now respond to F1 through F20, modifiers included.

And thanks to @Bwahharharrr you can also now bind to arrow keys with the ctrl, shift and alt modifiers.


High-Level Changelog

New

  • move cancelreader into a separate package by @muesli in #222
  • Exec, program.ReleaseTerminal and RestoreTerminal to re-use input and terminal by @muesli in #237
  • add support for shift/ctrl + arrow keys by @meowgorithm in #292
  • add function key support by @meowgorithm in #263

Changed

New Contributors

Full Changelog: v0.20.0...v0.21.0


The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or Slack.

Don't miss a new bubbletea release

NewReleases is sending notifications on new releases.