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
- spacebar now sends a
KeySpace
by @bashbunni in #289 and #315 - Program#Send, Program#Quit, and Program#Kill no longer provisional by @meowgorithm in #271
New Contributors
- @r-darwish made their first contribution in #225
- @wolves made their first contribution in #250
- @imranZERO made their first contribution in #254
- @iamjaredwalters made their first contribution in #279
- @bashbunni made their first contribution in #289
Full Changelog: v0.20.0...v0.21.0
Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or Slack.