Sha256: 818d8e67b0a16b7ecf131a0f95d1dea4bc085f3203d9e3bd5625d3823e909774

Contents?: true

Size: 649 Bytes

Versions: 1

Compression:

Stored size: 649 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(ENV['HOME'],'.tomatmux')
      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

1 entries across 1 versions & 1 rubygems

Version Path
tomatoharvest-0.0.1 lib/tomatoharvest/tmux.rb