require "formula"
require "utils"

def usage; <<-EOS
  Usage: brew cd <single-formula-name>
EOS
end

if ARGV.formulae.length != 1
  puts usage
  exit 1
end

f = ARGV.formulae.first
op = f.opt_prefix

odie "No install at #{op}" if !op.directory? || op.children.empty?

`cd #{op}`
exit 0

require "formula"
require "utils"

def usage; <<-EOS
  Usage: brew cd <single-formula-name>
EOS
end

if ARGV.formulae.length != 1
  puts usage
  exit 1
end

f = ARGV.formulae.first
fpfx = f.prefix

odie "No install at #{fpfx}" if !fpfx.directory? || fpfx.children.empty?

`echo "cd #{fpfx}" | tr "\n" " " | pbcopy`
puts "'cd #{fpfx}' on clipboard"

exit 0

Update brew cd cmd to place command on clipboard
Update brew cd cmd to place command on clipboard
