DEV Community

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

Fairly helpful terminal aliases for Ruby on Rails development

Flavio Antelo
Brazilian full-stack developer. Living and working in Paris. Regularly sharing productivity hot tips for web development.
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)"
Enter fullscreen mode Exit fullscreen mode

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 yarn bundler docker docker-compose brew)
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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'
gd='git diff'

# synchronizing with remote branch
ggpull='git pull origin "$(git_current_branch)"'
ggpush='git push origin "$(git_current_branch)"'
gp='git pull'
gf='git fetch'
Enter fullscreen mode Exit fullscreen mode

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'
Enter fullscreen mode Exit fullscreen mode

yarn

yd='yarn dev'
Enter fullscreen mode Exit fullscreen mode

docker-compose

dcupd='docker-compose up -d'
dcstop='docker-compose stop'
dcdn='docker-compose down'
Enter fullscreen mode Exit fullscreen mode

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


Are you into productivity hot tips for web development? I'm a Brazilian full-stack developer, living and working in Paris, and I regularly share articles like the one you've just read. Follow me on twitter to stay tuned.

Discussion (3)

Collapse
pabuisson profile image
Pierre-Adrien Buisson

I also like to use:

gp='git pull'
gf='git fetch'
gd='git diff'
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

Collapse
antelo profile image
Flavio Antelo Author • Edited

Thanks! Just added your suggestions to the post too :)

Collapse
trisrevill profile image
Tris Revill

This is so smart!!

Forem Open with the Forem app