Is it possible to script the following on OSX?
heroku run console
load 'init.rb'
The following does not work:
alias 'heroku_init=heroku run console; load "init.rb"'
It seems that the shell has to wait for the Heroku console to connect, or needs a way to send the load
command to the Heroku console instead of the bash shell.
Big ups to camilo-santana for the answer:
#!/usr/bin/expect -f
set timeout -1
spawn heroku console
expect "irb(main):001:0>"
send "load 'app/init.rb'\r"
interact
It can also be done with an alias:
alias 'hc=heroku run console -- -r ./app/init.rb'
What you want it to send load 'init.rb'
to the standard input of the heroku run console
program. You do that in the shell using the pipe operator:
echo "load 'init.rb'" | heroku run console
This works but notice it makes the console hang, if you want to input some more commands manually you can do:
{ echo "load 'init.rb'"; cat } | heroku run console
Hope this helps ;)