Sha256: 4c500b2cc0d6de5c84293e191b08e6598d01c7deec1f102aed51dc4b8f0bd11d

Contents?: true

Size: 667 Bytes

Versions: 2

Compression:

Stored size: 667 Bytes

Contents

module TomatoHarvest
  class Tmux

    def update(time)
      write_tmux_time time
      refresh_tmux_status_bar
    end

    private

    def tmux_time(time)
      mm, ss = time.divmod(60)
      ss = ss.to_s.rjust(2, "0")
      "#[default]#[fg=green]#{mm}:#{ss}#[default]"
    end

    def write_tmux_time(time)
      path = File.join(TomatoHarvest::Config::GLOBAL_DIR, 'tmux')
      File.open(path, 'w') do |file|
        file.write tmux_time(time)
      end
    end

    def refresh_tmux_status_bar
      pid = Process.fork do
        exec "tmux refresh-client -S -t $(tmux list-clients -F '\#{client_tty}')"
      end
      Process.detach(pid)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tomatoharvest-0.1.1 lib/tomatoharvest/tmux.rb
tomatoharvest-0.1.0 lib/tomatoharvest/tmux.rb