iTerm2: inline images(Ruby)

Because Python is slower on my machine, I made a little script to use the proprietary escape code of iTerm2 for printing pictures inline.

Nothing fancy, just to exercice.

require "base64"

def printi(α)
    χtmp = nil
    File.open(α, 'rb') { |χf|
        χtmp = Base64.encode64(χf.read)
    }
    puts("\x1b]1337;File=name=#{Base64.encode64(α)};inline=1:" + χtmp + "\a\n")
end
Advertisements