Class: Lolcommits::Plugin::TermOutput

Inherits:
Base
  • Object
show all
Defined in:
lib/lolcommits/plugin/term_output.rb

Instance Method Summary collapse

Instance Method Details

#configure_options!Hash, Nil

Prompts the user to configure the plugin’s options. The default superclass method will ask for the ‘enabled` option to be set.

Returns:

  • (Hash)

    hash of configured options ‘{ enabled: true/false }`

  • (Nil)

    if this terminal does not support this plugin



16
17
18
19
20
21
22
23
# File 'lib/lolcommits/plugin/term_output.rb', line 16

def configure_options!
  if terminal_supported?
    super
  else
    puts "Sorry, this terminal does not support this plugin (requires iTerm2)"
    {}
  end
end

#run_capture_readyObject

Post-capture hook, runs after lolcommits captures a snapshot. If the # terminal is supported (and we have commits) the lolcommit image is rendered inline to the terminal output (with the commit message).

See here for more details: iterm2.com/documentation-images.html



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/lolcommits/plugin/term_output.rb', line 33

def run_capture_ready
  if terminal_supported?
    if !runner.vcs_info || runner.vcs_info.repo.empty?
      debug 'repo is empty, skipping term output'
    elsif !image_path
      debug 'lolcommit videos not supported'
    else
      debug "rendering image in iTerm"
      base64 = Base64.encode64(open(image_path, &:read).to_s)
      puts "#{begin_escape}1337;File=inline=1:#{base64};alt=#{runner.message};#{end_escape}\n"
    end
  else
    debug 'Terminal not supported (requires iTerm2)'
  end
end