LoginSignup
0
1

More than 5 years have passed since last update.

ロゴをiTerm2でソッコー表示

Posted at

以下のスクリプトをパスの通っているところに配置し

logo bash

とするとiTerm2のシェルエクステンションの機能でターミナル上にbashのロゴを表示する。

logo
#!/usr/bin/env ruby

require 'open-uri'
require 'nokogiri'
require 'net/http'
require 'uri'
require 'erb'
include ERB::Util

puts "Usage: #{$0} facebook twitter ..." unless ARGV.count > 0

ARGV.each_with_index do |arg, i|
  q=url_encode arg
  url="http://instantlogosearch.com/?q=#{q}"

  charset=nil
  html=open(url) do |f|
    charset=f.charset
    f.read
  end

  doc=Nokogiri::HTML.parse html, nil, charset
  next unless doc!=nil
  node=doc.xpath('//div[@class="brand-logo__download-ctas"]')[0]
  next unless node!=nil
  imgurl=node.css('a')[1].attribute('href').value
  next unless imgurl!=nil
  system "curl -s #{imgurl} | ~/.iterm2/imgcat"
end
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1