• Stars
    star
    395
  • Rank 109,040 (Top 3 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 14 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ruby interactive print loop - A light, modular alternative to irb

Description¶ ↑

ripl is a light shell that encourages common middleware for shells i.e. rack for ruby shells. It is also a modular alternative to irb. Like irb, it loads ~/.irbrc, has autocompletion and keeps history in ~/.irb_history. Unlike irb, it is highly customizable via plugins and supports commands i.e. ripl-play. This customizability makes it easy to build custom shells (i.e. for a gem or application) and complex shells (i.e. for the web). Works on ruby 1.8.7 and greater.

Install¶ ↑

If you have readline, install ripl with:

gem install ripl

If you don’t have readline, first install ripl with a pure ruby readline:

gem install ripl rb-readline -- --without-readline

Then, add the following to ~/.riplrc:

Ripl.config[:readline] = 'rb-readline'
Ripl.config[:completion] = {:readline => :ruby }

Setup¶ ↑

To make your first ripl experience smoother, install these plugins:

# Adds multi-line evaluation
gem install ripl-multi_line

# Ignore errors caused by irb-specific configuration in ~/.irbrc
gem install ripl-irb

# Add to ~/.riplrc
require 'ripl/multi_line'
require 'ripl/irb'

Usage¶ ↑

$ ripl
>> ...

Documentation¶ ↑

To view ripl’s man page:

# If installed with rubygems
$ gem install gem-man
$ gem man ripl

To view ripl’s documentation online, read [the source](github.com/cldwalker/ripl/blob/master/man/ripl.1.ronn) or [the html version](rawgit.com/cldwalker/ripl/master/man/ripl.1.html).

Coming from irb¶ ↑

When first trying ripl, you may experience errors in your ~/.irbrc due to an irb-specific configuration. In order to have ripl and irb coexist peacefully, you should silence these errors. To silence them without touching your ~/.irbrc, install the ripl-irb gem. This ripl plugin fakes irb’s existence and points to ripl equivalents for your irb configurations. Otherwise, if you don’t mind modifying ~/.irbrc, wrap your irb-specific configuration in a block as follow:

if defined? IRB
  IRB.conf[:BLAH] = 'blah'
  # ...
end

Comparison to Irb¶ ↑

  • Similar to irb

    • Reads ~/.irbrc on startup

    • Appends to ~/.irb_history on exit

    • Autocompletion (from bond)

    • _ for last result

    • Type exit, quit or press Ctrl-D to exit

    • 6 common commandline options: -f, -r, -I, -d, -h, -v

    • IRB.conf -> Ripl.config

    • Handles Ctrl-C quietly

  • Enhancements over irb

    • ~290 lines (doc included) vs irb’s 5000+ lines

    • Easily extendable with plugins

    • Tests and documentation!

    • Customizable completion and completion of method arguments (from bond)

    • Easy to create custom shells for gems and apps i.e. Ripl.start

    • Easy to create and invoke ripl commands

    • Create console commands in a simple, modular way

    • Custom commandline options can be added via a plugin

    • ~/.irbrc errors caught

    • Well-integrated internationalization (see ripl-i18n)

  • Different from irb

    • No multi-line evaluation by default (but there is a plugin, ripl-multi_line).

    • No irb subsessions or workspaces (though ripl has jumps via ripl-commands)

    • Some IRB.conf features aren’t supported yet (see ripl-irb for details)

Note: Irb features not in ripl can be implemented as plugins.

Plugins¶ ↑

A ripl plugin is a module that is included into Ripl::Shell or extended into Ripl::Runner. Being simply modules, they can be packaged as gems and reused across shells as needed. ripl highly encourages plugins by loading them as early as possible and allowing them to extend most of ripl’s functionality.

As an example plugin, let’s color error messages red:

require 'ripl'

# To try place in ~/.riplrc
module Ripl
  module RedError
    def format_error(error)
      "\e[31m#{super}\e[m"
    end
  end
end
Ripl::Shell.include Ripl::RedError

Note this plugin extends format_error() by invoking the original format_error() with super. This is possible for any method that is available for extension by plugins. To see what methods are available for extension, see Ripl::Shell::API and Ripl::Runner::API.

If we want to add a config for this plugin, we can simply add a key to Ripl.config that matches the underscored version of the plugin name i.e. Ripl.config.

For available plugins, see Ripl Plugins below.

Configuration¶ ↑

Since ripl is highly customizable, it loads ~/.riplrc before it does anything. This ruby file should require and/or define plugins. Any ripl configurations via Ripl.config should also be done here. For an example ~/.riplrc, see mine.

Create Custom Shells¶ ↑

Creating and starting a custom shell is as simple as:

require 'ripl'
# Define plugins, load files, etc...
Ripl.start

Ripl.start takes options to customize your shell. For example if you wanted to start on a specific binding:

Ripl.start :binding => MyClass.instance_eval{ binding }

Create Commands¶ ↑

If you want to invoke your custom shell with ripl, make it a ripl command. To create one, create an executable in the format ripl-<command> and make sure it’s in your shell’s $PATH. For example, the file ripl-my_gem would be invoked with ripl my_gem. Note that with your command you can take arguments and parse your options as you please. For an example command, see ripl-rails.

Credits¶ ↑

  • janlelis and godfat for bug fix and tweaks

  • JoshCheek for bug fixes

  • postmodern for windows fixes and no history support

Bugs/Issues¶ ↑

Please report them on github.

Contributing¶ ↑

See here

Ripl Plugins¶ ↑

Ripl Shells¶ ↑

Shells built on top of ripl:

  • nirvana: A ruby web shell complete with autocomplete

  • fresh: An interesting ruby/system hybrid shell

  • ripl-johnson: A js shell based on johnson (firefox tracemonkey)

  • ronin: An exploit development platform using ripl for its console

  • tux: A sinatra shell

  • rack-webconsole: A rack middleware that adds a web shell to any rack app

Irb Alternatives¶ ↑

Some other irb alternatives to check out:

  • ir: nice and light

  • irb2: yehuda katz’s partial attempt at rewriting irb

  • dietrb: mac and ruby 1.9 specific

  • pry: featureful but heavy

More Repositories

1

hirb

A mini view framework for console/irb that's easy to use, even while under its influence. Console goodies include a no-wrap table, auto-pager, tree and menu.
Ruby
1,637
star
2

tux

Sinatra dressed for interactive ruby - a sinatra shell
Ruby
301
star
3

bond

Mission: Easy custom autocompletion for arguments, methods and beyond. Accomplished for irb and any other readline-like console environments.
Ruby
233
star
4

boson

A command/task framework similar to rake and thor built with extendability in mind.
Ruby
218
star
5

one9

commandline tool to convert 1.8 code to ruby 1.9.2. So what's your excuse for not upgrading to 1.9.2? ;)
Ruby
171
star
6

logseq-query

Clojure
159
star
7

vimdb

vim knowledge tabularized - search vim keys, options and more with great precision.
Ruby
157
star
8

table

Display ascii tables for almost any data structure with ease.
Clojure
107
star
9

lightning

Speed for your shell and the commandline
Ruby
74
star
10

bahia

commandline acceptance testing - aruba for non-cucumber test frameworks
Ruby
52
star
11

nirvana

A ruby web shell that is very ape and very nice
JavaScript
52
star
12

datomic-free

A wrapper around datomic-free to easily start and upgrade it
Shell
51
star
13

irbfiles

ripl/irb the way I like it (enhanced with boson)
Ruby
50
star
14

datomico

Use datomic with intention revealing names. Ease of use and sticking to datomic's principles are encouraged.
Clojure
49
star
15

bb-clis

Babashka CLIs
Clojure
48
star
16

has_machine_tags

A rails tagging gem implementing flickr's machine tags + maybe more (semantic tags)
Ruby
44
star
17

debugger-completion

Mission: auto-complete debugger
Ruby
43
star
18

datomic-client

ruby client for datomic's http api
Ruby
41
star
19

tag-tree

Explores the wicked combo of machine tag queries + their results as trees.
Ruby
28
star
20

alias

Creates, manages and saves aliases for class methods, instance methods, constants, delegated methods and more.
Ruby
25
star
21

console_update

A gem to edit your database records via the console and your favorite editor.
Ruby
21
star
22

ltfiles

my light table dotfiles
JavaScript
20
star
23

gem_grep

*Not being maintained. Any takers?* A gem command plugin which enhances the search command by providing extra search options and displaying results as a table.
Ruby
17
star
24

machinetag.js

jQuery plugins to search/parse machine tags and display machine tag trees.
JavaScript
16
star
25

dotfiles

config files for my most used apps
Shell
15
star
26

rubydoc

A repl tool to help rubyists find clojure equivalents
Clojure
15
star
27

wolf

Devour computational knowledge on the commandline with wolframalpha
Ruby
14
star
28

ripl-play

A ripl plugin to playback and record inputs in ripl
Ruby
14
star
29

logseq-config

13
star
30

ripl-rails

alternative to script/console using ripl
Ruby
11
star
31

dlint

Lint datomic-style datalog queries and rules. For clojure and clojurescript
Clojure
11
star
32

osx-setup

Set up my osx environment with a one-liner
Ruby
11
star
33

Mermaid

Light Table plugin that generates diagrams and flowcharts from text using mermaid
JavaScript
11
star
34

datomic-box

[wip] Spin up a running Datomic Free box from the commandline. Done.
Clojure
10
star
35

rbenv-travis

Run travis tests locally using rbenv rubies
Ruby
10
star
36

local_gem

Load/require any gem/library simply given its path. Great for nascent gems or for trying the latest code on a gem.
Ruby
10
star
37

lein-spell

Catch spelling mistakes in programming documents and clojure docstrings.
Clojure
9
star
38

gitbeam

Light Table plugin for seamless github interaction
JavaScript
9
star
39

sacha

An outliner for Light Table
JavaScript
9
star
40

photon

Light Table plugin to quickly open your most active projects
Clojure
9
star
41

gh-active-issues

A pedestal service that helps github maintainers grapple with their issues and helps users understand what's before their issue
Clojure
8
star
42

Sancho

Your trusty Clojure(Script) sidekick for LightTable. Includes grimoire and crossclj integration
JavaScript
8
star
43

Share

Collaborative editing for Light Table
JavaScript
7
star
44

nbb-clis

Nbb CLIs
Clojure
7
star
45

leinfiles

Handy functions for a clojure repl - most likely lein repl
Clojure
7
star
46

boson-more

Home for boson2 plugins
Ruby
7
star
47

queriac

Picking up where Yubnub left off..
Ruby
6
star
48

ripl-rack

script/console for rack using ripl
Ruby
6
star
49

ripl-em

interact with eventmachine code - asynchronously of course
Ruby
6
star
50

ripl-irb

A ripl plugin to smooth the transition from irb
Ruby
6
star
51

rbenv-plugin

Manage rbenv plugins
Ruby
6
star
52

tag

tag anything from the commandline
Ruby
6
star
53

ripl-commands

This ripl plugin adds commands to ripl that are similar to irb's
Ruby
6
star
54

ripl-hijack

hijack a ruby process a la ripl
Ruby
5
star
55

ripl-johnson

A full-featured javascript shell using johnson (mozilla's tracemonkey)
Ruby
5
star
56

ripl-i18n

A ripl plugin that let's ripl speak your language
Ruby
4
star
57

repl.js

jquery plugin to replify an html element
JavaScript
4
star
58

previewradio-pedestal

a sinatra to pedestal-service comparison
Clojure
4
star
59

sinatra-bootstrap

sinatra app bootstrapped by bootstrap and some
JavaScript
4
star
60

ripl-misc

some misc ripl plugin ideas
Ruby
4
star
61

ripl-color_error

ripl plugin to colorize errors
Ruby
4
star
62

lein-grep

A Leiningen plugin that renders meaningful search results.
Clojure
4
star
63

urls

easy bookmarking for the commandline and beyond
Ruby
4
star
64

bond-yard

bond plugin to generate completions for yard-documented methods
Ruby
3
star
65

fda-events

Exploratory app for FDA's drug adverse event API
Clojure
3
star
66

core

*Unfinished* Easily use and share your ruby extensions and other extension libraries ie ActiveSupport, facets
Ruby
3
star
67

lein-open

Open a jar in an editor easily
Clojure
3
star
68

emoji

middleware/interceptorware to add bundled emoji images
Clojure
3
star
69

github-contributions

App to show a github user's forks and contributions to each one. Using pedestal and SSE
Clojure
3
star
70

jrepl

*Work in progress* javascript shell with readline and autocompletion
JavaScript
3
star
71

bacon-bits

Making bacon a little tastier
Ruby
3
star
72

smart-ignore

LT plugin that auto-updates ignore-pattern based on current directories in a workspace
JavaScript
3
star
73

github_user_page.js

*broken with new layout* jquery plugin/ github bookmarklet to enhance github's user pages
JavaScript
3
star
74

emojinator

a silly app that slurps a url and emojinates any word that matches an emoji name
Clojure
2
star
75

sse-chat

simple sse chat example for pedestal, ported from sinatra
Clojure
2
star
76

ripl-debug

A ripl plugin that automatically passes a failed eval to ruby-debug
Ruby
2
star
77

bolt

[work in progress] - web commands a la queriac, done all clientside with rum/reactjs
Clojure
2
star
78

menu

More choices with less typing
Ruby
2
star
79

ripl-after_rc

A ripl plugin that defines blocks to run after ~/.irbrc
Ruby
2
star
80

logseq-clis

CLIs for logseq using nbb-logseq
Clojure
2
star
81

bacon-rr

rr adapter for bacon
Ruby
2
star
82

om-components

A collection of reusable om components [WIP]
Clojure
2
star
83

bender

smack-talking hubot
CoffeeScript
2
star
84

vimfiles

no horses were harmed while horsing around with this vim setup
Vim Script
2
star
85

websh

A sinatra web shell using ripl that deploys on Heroku.
JavaScript
2
star
86

robolot

your faithful async knight
Ruby
1
star
87

emacs.d

An emacs config based on emacs-starter-kit - optimized for ruby and clojure.
Emacs Lisp
1
star
88

ripl-ripper

ripl plugin for a multi-line ripl using ripper
Ruby
1
star
89

pedestal-dataflow-logger

An experiment in logging pedestal-app dataflow internals
Clojure
1
star
90

urls-web

web interface to urls
JavaScript
1
star
91

atomfiles

JavaScript
1
star
92

semtag.me

pedestal app that communicates via clojure data using CORS requests
Clojure
1
star
93

rip-licious

A tasty collection of rip plugins
Ruby
1
star
94

rip-ext

Rip plugin to easily synchronize gem environments across ruby versions
Ruby
1
star
95

psycho

Going psycho with syck to psych conversions? Let psycho handle this syck-psych-o-ness!
Ruby
1
star
96

is_it_ec2

is it ec2?
JavaScript
1
star
97

readline.js

jquery plugin to bring readline to the hoi polloi
JavaScript
1
star
98

migration_sql

Generate migration sql for Rails apps and Sequel
Ruby
1
star
99

link-checker

A multi-threaded link-checker powered by pedestal and SSE
Clojure
1
star
100

git-puns

Atom package to git some git laughs
Clojure
1
star