Skip to content

Instantly share code, notes, and snippets.

@jugyo
Created September 6, 2013 06:37
Show Gist options
  • Save jugyo/6460280 to your computer and use it in GitHub Desktop.
Save jugyo/6460280 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
def ask(message)
print "#{message} [Y/n] "
case gets.strip
when /n/i
else
yield
end
end
def ask_and_execute(command)
ask("`#{command}`") do
system command
end
end
# Example
ask_and_execute 'cd ~'
ask_and_execute 'mkdir bar'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment