speg03の雑記帳

主に未来の自分のために試したことなどを記録しています

Termtterのuri-openに上限をつける

uri-open listしたときにいっぱい出てくるのが嫌だったので,保持するURIの数に上限をつけましょうと.

まぁなんてことのない,そんだけ.

diff --git a/lib/plugin/uri-open.rb b/lib/plugin/uri-open.rb
index c9946ca..23fdd3f 100644
--- a/lib/plugin/uri-open.rb
+++ b/lib/plugin/uri-open.rb
@@ -1,5 +1,7 @@
 # -*- coding: utf-8 -*-

+configatron.plugins.uri_open.set_default(:max_of_uris, 10)
+
 module Termtter::Client
   public_storage[:uris] = []

@@ -13,6 +15,11 @@ module Termtter::Client
         end
       end
     end
+
+    max_of_uris = configatron.plugins.uri_open.max_of_uris
+    if public_storage[:uris].length > max_of_uris then
+      public_storage[:uris] = public_storage[:uris][0, max_of_uris]
+    end
   end

   def self.open_uri(uri)