Sha256: 4f146dc7bc019ac407178203008e0f4fa727a31f93cd058a1c764dc79f2cdf33
Contents?: true
Size: 987 Bytes
Versions: 16
Compression:
Stored size: 987 Bytes
Contents
require 'rib/core/history' # dependency module Rib::SqueezeHistory extend Rib::Plugin Shell.use(self) # --------------- Rib API --------------- # squeeze history in memory too def loop_once return super if SqueezeHistory.disabled? begin input, last_input = history[-1], history[-2] rescue IndexError # EditLine is really broken, to_a is needed for it array = history.to_a input, last_input = array[-1], array[-2] end history.pop if input.to_s.strip == '' || (history.size > 1 && input == last_input) super end # --------------- Plugin API --------------- # write squeezed history def write_history return super if SqueezeHistory.disabled? config[:history] = squeezed_history super end private def squeezed_history history.to_a.inject([]){ |result, item| if result.last == item || item.strip == '' result else result << item end } end end
Version data entries
16 entries across 16 versions & 1 rubygems