The internal of go-prompt: How to control the rich terminal UI (Part I).

Aug 25 · 6 min read

A brief history of the terminal.

Image refers from
Image refers from

VT100 escape sequences

Change the terminal color

How to get the window size of Terminal emulator.

type winsize struct {
Row uint16
Col uint16
X uint16
Y uint16

func getWinSize(fd int) (row, col uint16, err error) {
var ws *winsize
retCode, _, errno := syscall.Syscall(
syscall.SYS_IOCTL, uintptr(fd),
if int(retCode) == -1 {
return ws.Row, ws.Col, nil
Spread the progress bar with the window column size.
This program has a problem that it doesn’t follow the changes of window size.
Follow the changes of window size

What you’ll learn next?



Written by

Creator of go-prompt and kube-prompt. github: c-bata

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade