Go wrapper around libedit
, a replacement to GNU readline using the BSD license.
How to use:
go build
/ go install
test/example.go
for a demo.Init()
once. Then call SetLeftPrompt()
and
GetLine()
as needed. Finally call Close()
.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 unix/editline_unix.go
as follows:
#cgo linux CFLAGS
#cgo linux CPPFLAGS
to read: #cgo linux CPPFLAGS: -I/usr/include/editline -Ishim
#cgo linux LDFLAGS
to read: #cgo linux LDFLAGS: -ledit
macOS Mojave is shipped with a broken/restricted libedit where the completion API is not published. Because it is not possible to automatically detect macOS versions, go-libedit will use a reduced autocompletion facility on all versions of macOS instead.
This autocompletion facility lacks the following features from libedit:
(Only needed when upgrading the bundled libedit
to a newer version.)
This procedure should be ran on a Debian/Ubuntu system.
/etc/apt/sources.list
contains source repositories, i.e. the deb-src
lines are uncommented. Run apt-get update
as necessary.run:
$ sudo apt-get install libbsd libbsd-dev libncurses-dev`
$ cd src
$ bash refresh.sh