LoginSignup
0
0

More than 3 years have passed since last update.

vagrant環境でも、rails s でRailsを動かしたい

Last updated at Posted at 2020-01-15

環境

Ubuntu 16.04.5 LTS
Windows10
Vagrant

手順

Mac環境でRailsを動かすには、これでいいのだが、

rails s

Vagrant環境では、このように、いちいちコマンドが面倒くさい。

rails s -b 192.168.33.10 -p 3000

履歴から検索して、!してもいいのだが、もっと、サクッと動かしたい。

history | grep 33.10

.bashrcviで開いて、Shift + gで一番下に移動。

vi ~/.bashrc

下記の関数を追加する

function rails () {
  if [[ "$@" =~ ^s$ ]]; then
    command rails s -b 192.168.33.10 -p 3000
  else
    command rails "$@"
  fi
}

変更した、.bashrcを反映させます。

source ~/.bashrc

rails sで、rails s -b 192.168.33.10 -p 3000が動いてくれました。

c'est fini :grin::clap:

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0