This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Termtter::Client | |
register_command( | |
:async, | |
:alias => :a, | |
:help => ['async COMMAND', 'asynchronously execute the command'], | |
:completion => lambda {|cmd, arg| | |
commands.map{|name, command| command.complement(arg)}. | |
flatten. | |
compact. | |
map{|i| "#{cmd} #{i}"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Termtter::Client.init do |t| | |
t.plug 'growl' | |
t.register_hook(:growl_filter, :point => :filter_for_growl) do |ss, e| | |
ss.select { |s| /jugyo|termtter/ =~ s['text'] } | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'gd2' | |
class GD2::Image | |
def resize_and_crop!(w, h) | |
w_rate = w / width.to_f | |
h_rate = h / height.to_f | |
if (1 - h_rate) > (1 - w_rate) # 縦方向の変化量の方が大きい場合 | |
# 横幅を基準にリサイズ | |
resize!(w, height * w_rate) | |
crop!(0, (height - h) / 2.0, w, h) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/plugins/defaults/stdout.rb b/lib/plugins/defaults/stdout.rb | |
index cb18184..07d64cb 100755 | |
--- a/lib/plugins/defaults/stdout.rb | |
+++ b/lib/plugins/defaults/stdout.rb | |
@@ -7,7 +7,7 @@ require 'tempfile' | |
config.plugins.stdout.set_default(:colors, (31..36).to_a + (91..96).to_a) | |
config.plugins.stdout.set_default( | |
:timeline_format, | |
- '<90><%=time%> [<%=status_id%>]</90> <<%=color%>><%=s.user.screen_name%>: <%=text%></<%=color%>> ' + | |
+ '<90><%=time%> [<%=status_id%>]</90> <<%=color%>><%=s.user.screen_name%></<%=color%>>: <%=text%> ' + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fileutils' | |
namespace :config do | |
desc "create config files" | |
task :create do | |
Dir['config/*.sample'].each do |filename| | |
FileUtils.cp(filename, filename.gsub('.sample', '')) | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.set_default(:confirm, false) | |
module Termtter | |
RubytterProxy.register_hook(:confirm, :point => :pre_update) do |*args| | |
if config.confirm && !Client.confirm("update #{args.first}") | |
raise CommandCanceled | |
end | |
args | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hash | |
def structize! | |
class << self | |
def id | |
self[:id] | |
end | |
def method_missing(name, *args) | |
if /(.*)=$/ =~ name.to_s | |
if args.size == 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def sort_by_conditions(*blocks) | |
raise ArgumentError, 'no block given' if blocks.empty? | |
sort do |a, b| | |
result = 0 | |
blocks.each do |block| | |
result = block.call(a, b) | |
break unless result == 0 | |
end | |
result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/termtter/default_config.rb b/lib/termtter/default_config.rb | |
index 4acebce..be61521 100644 | |
--- a/lib/termtter/default_config.rb | |
+++ b/lib/termtter/default_config.rb | |
@@ -4,3 +4,4 @@ config.set_default(:prompt, '> ') | |
config.set_default(:devel, false) | |
config.set_default(:timeout, 5) | |
config.set_default(:retry, 1) | |
+config.set_default(:force_escape_sequence, false) | |
diff --git a/lib/termtter/system_extensions.rb b/lib/termtter/system_extensions.rb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Kernel | |
def irb | |
require 'irb' | |
IRB.setup(nil) | |
irb = IRB::Irb.new(IRB::WorkSpace.new(binding)) | |
IRB.conf[:MAIN_CONTEXT] = irb.context | |
catch(:IRB_EXIT) do | |
irb.eval_input | |
end | |
end |