環境
- Intellij IDEA 2017.2.6
- rbenv
手順
Run -> Edit configurations に行き、 + をクリックして Ruby を選択

Configuration を下記画像のように設定
user_name
は適宜変更してください。project_folder
はrailsアプリのルートフォルダにします。Nameは表示名なのでなんでも大丈夫です。
Ruby script
を設定するところで、Finderが出てくるので Command shift .
で隠しファイル・フォルダを表示して選択するか、 Command shift g
で直接PATHを入力して設定する。
注意:ここで、Ruby scriptをwhich foreman
で出てくる/Users/user_name/.rbenv/shims/foreman
にするとIntellij IDEAがシェルスクリプトを実行するところでこけるので、元の実行ファイルを指定します。
Bundlerにチェックを入れる

以上です。
参考
RUBY-12023 how to run foreman within rubymine debug mode
rbenvの切り替えの仕組み…と、他言語での実験 - すぎゃーんメモ
今後調査
bundle
コマンドは/Users/user_name/.rbenv/shims/bundle
で実行できてるのに、なぜforeman
はこけるのか。
出てくるエラー
-e:1:in `load': /Users/user_name/.rbenv/shims/foreman:3: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '(' (SyntaxError)
[ -n "$RBENV_DEBUG" ] && set -x
^
/Users/user_name/.rbenv/shims/foreman:3: syntax error, unexpected ']', expecting end-of-input
[ -n "$RBENV_DEBUG" ] && set -x
^
from -e:1:in `<main>'