Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

my dotfiles

tree: b271f4579d
README.rdoc

My dotfiles.

You may reuse and redistribute this without any restrictions. No warranty. However, if you like to you may tell everybody who said something like “wow, i like your config”: “Yeah, that was written by Konstantin (or who ever he stole it from). That guy is freakin' awesome. Let's invite him to our party next wednesday.”

Just clone and do “rake install” (or “rake install:irb”).

.irbrc

See irb.png for a screenshot.

My .irbrc only loads files from .config/irb It is optimized for usage with multiple ruby versions (I'm using it for 1.8, 1.9, Rubinius and JRuby). You probably can skip each scripts but myirb.rb and engine.rb. Here is what the scripts do:

.config/irb/myirb.rb

Relies on color.rb. If you do not want colors, edit MyIRB.prompt and do not load color.rb. Sets the prompt.

Tries to load a couple of libraries but does not fail if unable to load them. I used to load ActiveSupport but happen to not like it anymore lately.

Most of this is optional, so if you installed it, but don't wanne use it, simply remove it from the list.

To use all of this features, do the following:

sudo gem sources -a http://gems.github.com
sudo gem install map_by_method what_methods english ruby2ruby hpricot mechanize duration rkh-stored_hash

Currently what_methods is not running on 1.9.

On Windows, you should also install Win32::Clipboard.

This are the libraries:

  • irb/completion: auto completion (tab tab)

  • irb/ext/save-history: readline history from former sessions

  • yaml

  • English

  • fileutils (it does “include FileUtils::Verbose”)

  • date

  • open-uri

  • stringio

  • pp

  • monitor (I use this internally)

  • rubygems

  • map_by_method (drnicwilliams.com/category/ruby/gems/map_by_method/)

  • what_methods (redhanded.hobix.com/inspect/stickItInYourIrbrcMethodfinder.html)

  • english/array (Array#conjunction, like Array#to_sentence from ActiveSupport)

  • english/inflect (String#plural and such)

  • english/string (String#word_wrap and such)

  • english/style (String#camelcase and such)

  • ruby2ruby

  • hpricot

  • mechanize

  • stored_hash

  • duration

.config/irb/color.rb

  • Simple ANSI color methods (in_blue, underlined, …)

  • Syntax highlighting in inspect and irb output:

    an_object.inspect               # <- not highlighted
    in_color { an_object.inspect }  # <- highlighted
    >> an_object
    => ... highlighted version of an_object ...
  • cool regex highlighting:

    show_regexp("hello", /l+/)
  • shorten long Enumerable#inspect:

    >> (0..20).to_a
    => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ... 11 elements]
    >> (0..20).to_a.show_all
    => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]

.config/irb/engine.rb

  • Makes sure RUBY_ENGINE is defined, defines RUBY_ENGINE_VERSION

  • Gives you rubinius?, mri? and jruby?.

  • Defines ruby_binary (you might want to change this on windows setups)

.config/irb/commands.rb

  • call external programms as ruby functions:

    ping "google.com"
    wget :r, "http://github.com"
    gem_install "ruby2ruby"
  • use external editor inside irb. can be extended to use any editor (currently it understands vi, vim, evim, ex, gvim, joe, kate and nano). try this:

    vi
    last_edit
    vi :yaml
    last_edit
    name_edit :foo
    edit_to_gist :foo # if .config/irb/gist is loaded
    edit_to_file :foo, "foo.yaml"
    vi ["i wonder what...", "... will happen?", { "foo" => "bar" }]
    name_edit :bar
    last_edit :foo
    last_edit :bar
    edit_to_file "bar.yaml"
    last_edit :foo
    edit_to_gist :foo
    # (only if you have ruby2ruby installed):
    vi MyIRB
    def foo; :bar; end
    vi method(:foo)
    edit_to_file "foo.rb"
    edit_to_gist
    edit_to_clipboard
  • File.write (like File.read):

    File.write "foo.txt", "bar"
  • Class#publicize_methods - blog.jayfields.com/2007/11/ruby-testing-private-methods.html

  • Ensures you have Object#tap

.config/irb/gist.rb

  • post from irb to gist:

    gist = Gist.new
    gist.text   = "<b>hello</b>"
    gist.format = ".xml"
    gist.commit
    gist.text   = "hello"
    gist.commit
  • post your scripts to gist:

    class SomeClass; end
    vi SomeClass
    Gist.post

.config/irb/rails.rb

  • defines is_rails?

  • railsifies prompt

  • uses STDOUT for logging

Something went wrong with that request. Please try again.