Skip to content

Instantly share code, notes, and snippets.

@colszowka
Created February 17, 2014 14:02
Show Gist options
  • Save colszowka/9051108 to your computer and use it in GitHub Desktop.
Save colszowka/9051108 to your computer and use it in GitHub Desktop.
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