LoginSignup
3
3

More than 5 years have passed since last update.

brew cask list +バージョン表示(Ruby版)

Last updated at Posted at 2015-12-22

こんにちは。
brew cask list +バージョン表示 」について、今度は Ruby で書き、未インストールの最新バージョンがあれば出力を付加しました1

$ ./brew_cask_list.rb
gimp               2.8.14 (< 2.8.16-x86_64)
mactex             20150613
brew_cask_list.rb
#!/usr/bin/ruby
cask_list = `brew cask list 2>&1`
ls_caskroom = "ls -C /opt/homebrew-cask/Caskroom/"
cask_list.each_line do |x|
    print_out = [].push(x.strip.ljust(18, " "), " ", `#{ls_caskroom + x}`.split.
join(" "))
    cask_info = `brew cask info #{x}`.split("\n")
    if cask_info.grep(/Not installed/) != [] && cask_info[0] !~ /:\slatest\z/ th
en
        print_out.push(" (< ", cask_info[0].split[1], ")")
    end
    puts print_out.join
end

なお、ある cask をアップグレードしたい場合には、新規インストールと同じコマンドで行うので、上記のgimpの例で未インストールだった2.8.16-x86_64へのアップグレードは:

$ brew cask install gimp
  • その後、古いバージョンの2.8.14をアンインストールするには:
$ rm -r /opt/homebrew-cask/Caskroom/gimp/2.8.14
  • もし、gimpの全バージョンをアンインストールするには:
$ brew cask uninstall --force gimp


  1. ただしバージョン番号をlatestとして扱っているcaskに対しては、本物の最新バージョン情報を得られません。 

3
3
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
3
3