Skip to content

Instantly share code, notes, and snippets.

@chrisk
Created January 9, 2009 01:46
Show Gist options
  • Save chrisk/44987 to your computer and use it in GitHub Desktop.
Save chrisk/44987 to your computer and use it in GitHub Desktop.
Some old dotfiles from aught-nine
# By default up/down are bound to previous-history
# and next-history respectively. The following does the
# same but gives the extra functionality where if you
# type any text (or more accurately, if there is any text
# between the start of the line and the cursor),
# the subset of the history starting with that text
# is searched.
"\e[B": history-search-forward
"\e[A": history-search-backward
# Include system wide settings which are ignored
# by default if one has their own .inputrc
$include /etc/inputrc
#!/usr/bin/ruby
require 'rubygems'
require 'shell'
require 'wirble'
require 'method_lister'
# Override the command processor widget for inserting system commands so
# that it behaves more like path-processing: earlier commands take precedence.
require 'shell/command-processor'
module FixAddDelegateCommandToShell
def self.extended(obj)
class << obj
alias_method :add_delegate_command_to_shell_override, :add_delegate_command_to_shell unless method_defined?(:add_delegate_command_to_shell_override)
alias_method :add_delegate_command_to_shell, :add_delegate_command_to_shell_no_override
end
end
def add_delegate_command_to_shell_no_override(id)
id = id.intern if id.kind_of?(String)
name = id.id2name
if Shell.method_defined?(id) or Shell::Filter.method_defined?(id)
Shell.notify "warn: Not overriding existing definition of Shell##{name}."
else
add_delegate_command_to_shell_override(id)
end
end
end
Shell::CommandProcessor.extend(FixAddDelegateCommandToShell)
# Allow Shell system commands to take :symbols too, to save a little typing.
require 'shell/system-command'
class Shell
class SystemCommand
alias_method :initialize_orig, :initialize
def initialize(sh, command, *opts)
opts.collect! {|opt| opt.to_s }
initialize_orig sh, command, *opts
end
end
end
# Provide me with a shell inside IRB to save quitting and restarting, or
# finding that other terminal window.
def shell
unless $shell
Shell.install_system_commands '' # no prefix
$shell = Shell.new
end
$shell
end
Wirble.init
Wirble.colorize
load File.dirname(__FILE__) + '/.railsrc' if $0 == 'irb' && ENV["RAILS_ENV"] == "development"
#!/usr/bin/ruby
def method_missing(method, *args, &block)
User.find_by_gamername(method.to_s) || super
end
def sql(query)
ActiveRecord::Base.connection.select_all(query)
end
def change_log(stream)
ActiveRecord::Base.logger = Logger.new(stream)
ActiveRecord::Base.clear_all_connections!
end
def show_log
change_log(STDOUT)
end
def hide_log
change_log(nil)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment