loading...
Cover image for Fairly helpful terminal aliases for Ruby on Rails development
Doctolib Engineering

Fairly helpful terminal aliases for Ruby on Rails development

fwuensche profile image Flavio Wuensche Updated on ・2 min read

Install oh-my-zsh

If you're not yet using, I do recommend Robby Russel's oh-my-zsh extension for your terminal. It's a framework to manage your zsh configuration and, if you already decided to install it, just run:

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Activate relevant oh-my-zsh plugins

To add new plugins, just open ~/.zshrc in your favorite text editor, i.e, code ~/.zshrc 😉 and around the third paragraph you'll find the plugins line. Mine looks like this:

# Which plugins would you like to load?
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git ruby rails bundler docker docker-compose brew)

How to get to know your commands?

To get a list of aliases you can grep your alias command, for instance:

alias | grep rails
#=> and it should list all your rails shortcuts

My personal favorites

git

# working with branches
gcb='git checkout -b'
gco='git checkout'
gcm='git checkout master'
gmom = git merge origin/master

# handling changes
gaa='git add --all'
glol=(beautiful git log)
gsta='git stash push'
gstaa='git stash apply'
gcam='git commit -a -m'

# synchronizing with remote branch
ggpull='git pull origin "$(git_current_branch)"'
ggpush='git push origin "$(git_current_branch)"'

rails

rc='rails console'
rs='rails server'
rdm='rake db:migrate'
rdr='rake db:rollback'
rdrs='rake db:reset'
rrg='rake routes | grep'
rt='rake test'

docker-compose

dcupd='docker-compose up -d'
dcstop='docker-compose stop'
dcdn='docker-compose down'

Hope that speeds up your git workflow, even if just by a few seconds 💨

If you have any questions or suggestions, leave a comment below. And if you want to contribute to building the future of healthcare, Doctolib is hiring Ruby on Rails developers in Paris, Berlin, Nantes, and more yet to come...

Doctolib Engineering

We are hiring in all positions. If you want to build a better healthcare system, visit our career page: https://about.doctolib.fr/jobs

Discussion

markdown guide
 

I also like to use:

gp='git pull'
gf='git fetch'
gd='git diff'

And for the routes, you might want to have a look at fzf, a fuzzy-finder you might already know. You can pipe anything to fzf.... rails routes for instance 😇

$ rails route | fzf

and boum, you can fuzzy search on all your routes (prefixing your search with a simple quote switch to exact search). Pretty useful!