Go wrapper around libedit, a replacement to GNU readline using the BSD license.
Prerequisites: ncurses/terminfo development headers.
How to use:
go build/go install- see
test/example.gofor a demo. - basic idea: call
Init()once. Then callSetLeftPrompt()andGetLine()as needed. Finally callClose().
By default, the go-libedit package uses the bundled libedit
sources on GNU/Linux, so that go get works out of the box.
To force the package to use a system-wide libedit instead, edit edit.go as follows:
- remove the line containing
#cgo linux CFLAGS - change the line containing
#cgo linux CPPFLAGSto read:#cgo linux CPPFLAGS: -I/usr/include/editline -Ishim - change the line containing
#cgo linux LDFLAGSto read:#cgo linux LDFLAGS: -ledit
(Only needed when upgrading the bundled libedit to a newer version.)
This procedure should be ran on a Debian/Ubuntu system.
-
ensure that
/etc/apt/sources.listcontains source repositories, i.e. thedeb-srclines are uncommented. Runapt-get updateas necessary. -
run:
$ sudo apt-get install libbsd libbsd-dev libncurses-dev` $ cd src $ bash refresh.sh