Reputation: 458
i'm new to development in general and I'm starting with rails. I learned via the Hartl Rails Tutorial (and a few other resources) and am using cloud9 IDE. I noticed that every time I want to launch the server in C9 i need to type the following:
rails s -b $IP -p $PORT
Is there a shortcut, hotkey, alias etc so I can simply type something like "rails s"? Seems unnecessarily annoying to have to type that whole thing out every single time.
Thanks!
Upvotes: 1
Views: 884
Reputation: 156
Don't forget to restart your C9 IDE. Otherwise the .bash_aliases nor .bashrc won't be recognized as updated.
Upvotes: 1
Reputation: 5532
To do this, you'll need to set a bash alias. To launch it with "launchRails" you'd add a line like this to your ~/.bashrc
or ~/.bash_aliases
files (either one will work):
alias railsAlias="rails s -b $IP -p $PORT"
You can open up those files with c9 ~/.bashrc
.
For a multi-word alias like "rails command", you might consider a solution like this one.
Source: How and where to set bash alias
Upvotes: 2
Reputation: 10073
To use railss
as an alias, run this in the Cloud9 terminal:
echo -e "\nalias railss='rails server -b \$IP -p \$PORT'" >> ~/.bash_aliases
This will append the railss
alias to the end of the provided ~/.bash_aliases
file.
Open a new Terminal tab on Cloud9 and the railss
alias should work in the new Terminal tab. From now on you can use railss
instead of rails s -b $IP -p $PORT
.
At time of writing ~/.bash_aliases
is provided on Cloud9 by default. If you don't have the ~/.bash_aliases
file, use ~/.bashrc
instead.
Optional: to make the railss
alias available in old, already-opened Terminal tabs, run source ~/.bash_aliases
.
Upvotes: 1