Skip to content

Instantly share code, notes, and snippets.

@lucasefe
Created July 11, 2012 19:59
Show Gist options
  • Save lucasefe/3092902 to your computer and use it in GitHub Desktop.
Save lucasefe/3092902 to your computer and use it in GitHub Desktop.
run commands on a single app context
# heroku-cli --app my-heroku-app
[ my-heroku-app ] >
#!/usr/bin/env ruby
require 'readline'
def prompt
if ARGV.include?("--app")
"[ #{ARGV[ARGV.index("--app") + 1]} ] > "
else
"> "
end
end
stty_save = `stty -g`.chomp
trap('INT') { system('stty', stty_save); exit }
cmd_prefix = ARGV.join(" ")
while cmd = Readline.readline(prompt, true)
exit if /exit/ =~ cmd
if cmd != ""
full_cmd = "heroku #{cmd} #{cmd_prefix}"
puts " [executing #{full_cmd}]"
system(full_cmd)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment