Skip to content
A Ruby wrapper around the small self-contained alternative to Readline and Libedit called Linenoise (https://github.com/antirez/linenoise).
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
ext/linenoise
lib
spec
.gitignore
.rspec
.rubocop.yml
CHANGELOG.md
Gemfile
LICENSE.md
README.md
Rakefile
linenoise.gemspec

README.md

Linenoise Ruby

CircleCI Gem Version Documentation Status Downloads

Introduction

The Linenoise gem is a wrapper around the small self-contained alternative to Readline and Libedit called Linenoise.

Features

  • History support
  • Completion
  • Hints (suggestions at the right of the prompt as you type)
  • Single and multiline editing mode with the usual key bindings

Installation

Bundler

Add the Linenoise gem to your Gemfile:

gem 'linenoise', '~> 1.1'

Manual

Invoke the following command from your terminal:

gem install linenoise

Examples

Basic example

require 'linenoise'

while buf = Linenoise.linenoise('> ')
  p buf
end

Completion

require 'linenoise'

LIST = %w[
  search download open help history quit url next clear prev past
].freeze

Linenoise.completion_proc = proc do |input|
  LIST.grep(/\A#{Regexp.escape(input)}/)
end

while line = Linenoise.linenoise('> ')
  p line
end

Hints

require 'linenoise'

Linenoise.hint_proc = proc do |input|
  case input
  when /git show/
    ' [<options>] [<object>...]'
  when /git log/
    ' [<options>] [<revision range>]'
  else
    ' --help'
  end
end

while line = Linenoise.linenoise('> ')
  p line
end

More examples and full API explanation is available on the documentation page.

Development

Running tests

bundle exec rake compile spec

Launching development console

bundle exec rake compile console

Contact

In case you have a problem, question or a bug report, feel free to:

License

The project uses the MIT License. See LICENSE.md for details.

You can’t perform that action at this time.