require_relative './historian'
Historian.humble_run_id
historian = Historian.new("--display=env #{ARGV.join(' ')}", false)
historian.register_keys_virtual([ENTER], lambda { |_, _, options|
}, msg: 'Apply multiple envs')
clear = false
historian.register_keys_virtual(%w[c C], lambda { |_, _, _|
clear = true
}, msg: 'Clear the selected env')
result = historian.run()
options = result.options
File.open(HS_ENV.env_var(:source), 'w') do |file|
options.each do |opt|
case ENV['SHELL'].split('/').last
when 'fish'
opt.envs.each do |e|
if clear
file.write("set -e #{e[0]}")
else
file.write("set -gx #{e[0]} #{e[1]}")
end
end
else
warn "#{ENV['SHELL']} not supported"
end
end
end