Create a gist now

Instantly share code, notes, and snippets.

IRB improvements: Command history, coloring, more shell like commands cd, pwd, dir, cat
# kate: syntax ruby;
# -*- mode: ruby -*-
# vi: set ft=ruby :
# IRB improvements: Command history, coloring, more shell like commands cd, pwd, dir, cat
# Use powerful shell commands
# dir
# dir '**/*.rb'
# cd 'app'
# pwd
# cat 'config/environment.rb'
# dir('vendor/plugins/*').each do |d| inside_dir(d) {`git pull`} end
# Developed by umur dot ozkul at gmail dot com
require 'pp'
require 'irb/completion'
IRB.conf[:PROMPT_MODE] = :SIMPLE
require 'rubygems'
require 'wirble'
#require 'utility_belt' #utility belt is not up-to-date!
Wirble.init
Wirble.colorize
require 'active_support'
require 'fileutils'
alias q exit
# See http://www.ruby-doc.org/core/classes/FileUtils.html
class Object
def cd d, options={}; FileUtils.cd d, options; end
def pwd; FileUtils.pwd; end
def dir d='*'; Dir[d]; end
alias ls dir
def cat file; puts `cat #{file}`; end
def ln_s old, new, options={}; FileUtils.ln_s old, new, options; end
def mv file, new_file, options={}; FileUtils.mv file, new_file, options; end
def rm list, options={}; FileUtils.rm list, options; end
def mkdir dirname, options={}; FileUtils.mkdir dirname, options; end
def touch list, options={}; FileUtils.touch list, options; end
def inside_dir d, &block
b = pwd
begin
cd d
block.call
ensure
cd b
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment