Skip to content

Instantly share code, notes, and snippets.

@jamie
Created October 17, 2013 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamie/7030049 to your computer and use it in GitHub Desktop.
Save jamie/7030049 to your computer and use it in GitHub Desktop.
function command_not_found_handler() {
~/bin/command-not-found $*
}
#!/usr/bin/env ruby
command = ARGV.first
def run(cmd)
$stderr.puts "Running #{cmd.inspect} instead"
system(cmd)
end
case
# Paste git repo url to clone it
when command =~ /^git(@|:\/\/).*\.git$/
run("git clone #{command.inspect}")
# paste compressed url to download+extract it
when command =~ /^(?:ftp|https?):\/\/.+\.t(?:ar\.)?gz$/
run("curl #{command.inspect} | tar xzv")
when File.exist?("./tmp/isolate/ruby-1.8/bin/#{command}")
run("rake isolate:sh['#{ARGV.join(' ')}']")
when File.exist?("./.bundle/config") && (File.exist?("./bin/#{command}") || File.exist?("./bins/#{command}"))
run("bundle exec #{ARGV.join(' ')}")
else
exit 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment