Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A very simple shell for the heroku CLI that allows you to avoid typing `heroku` and `--app app_name` all the time
#!/usr/bin/env ruby
require "readline"
APP_NAME = ARGV[0]
unless APP_NAME
STDERR.puts "Usage: #{$0} HEROKU_APP_NAME"
exit 1
end
def bold(string)
"\e[0;1m#{string}\e[m"
end
Readline::HISTORY.push 'foobar'
while line = Readline.readline("heroku --app #{bold APP_NAME} > ", true)
exit 0 if line.include? 'exit' or line.include? 'quit'
if line.strip.length > 0
command = "heroku #{line.strip} --app #{APP_NAME}"
puts "$ #{bold command}"
begin
system command
rescue Interrupt
sleep 0.5
end
else
puts "/join #noop"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment