Skip to content

Instantly share code, notes, and snippets.

Forked from MyklClason/.bash_aliases
Created February 12, 2020 19:46
Show Gist options
  • Save Azzawie/95506750021cf3f13e3aee766b691293 to your computer and use it in GitHub Desktop.
Save Azzawie/95506750021cf3f13e3aee766b691293 to your computer and use it in GitHub Desktop.
List of useful terminal bash aliases for Ruby On Rails, Cloud9, Git and more. What are bash aliases: What does && and ; do?
# About Aliases:
alias ls='ls --color=auto -F'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias less="less -R "
alias mysqldump="mysqldump --user=$C9_USER --host=$IP"
alias php="php -c ~/workspace/php.ini"
alias ..="cd .."
alias ctw='killall tmux' # Close all terminal windows. Acts more as a hard reset for terminal windows in Cloud9.
# ----------------------
# Cloud9 Aliases
# ----------------------
alias c9ct="sudo rm -rf /tmp/*" # Clear the temp files folder
alias c9mr="sudo /etc/init.d/mysql start && sudo service redis-server start" # Start mysql2 and redis servers
# ----------------------
# Django
# ----------------------
alias pmrs='python runserver $IP:$PORT'
alias c9ds='python runserver $IP:$PORT' # C9, Django Server
alias pmcs='python collectstatic'
alias pmm='python migrate'
# ----------------------
# Python
# ----------------------
alias pelr='pipenv lock --requirements'
alias pir='pip install -r requirements.txt'
# ----------------------
# Rails Aliases
# Many from:
# ----------------------
alias c9s="rails s -b $IP -p $PORT" # Cloud 9 server, Run rails server
alias c9sp="pgr && rails s -b $IP -p $PORT" # Cloud 9 Server Postgres, restarts Postgres server then runs rails server
alias c9p="rails s -b $IP -p $PORT puma" # Cloud 9 server (Puma), Run rails server via Puma
alias c9pr='pgr && sudo service redis-server start && c9s'
alias rg='rails generate'
alias rgc='rails generate controller'
alias rgm='rails generate migration'
alias rgbt='rails g bootstrap:themed'
alias rdbm='rake db:migrate'
alias rdbm0='rake db:migrate VERSION=0'
alias rdbmu='rake db:migrate:up'
alias rdbmd='rake db:migrate:down'
alias rdbr='rake db:rollback'
alias rdbc='rake db:create'
alias rdbp='rake db:drop'
alias rdbs='rake db:seed'
alias rdbhr='pgr && rake db:drop db:create db:migrate db:schema:dump db:setup' # db hard reset
alias rr='rake routes'
alias rrg='rake routes | grep'
alias b='bundle'
alias ber='bundle exec rspec'
alias bi='bundle install'
alias biwp='bundle install --without production'
alias bu='bundle update'
alias bui='bundle update && bundle install' # Bundle update and install, update doesn't touch Gemfile.lock
# Rubocop
alias rc='rubocop' # Run rubocop
alias rca='rubocop -a' # Run rubocop autocorrect
alias rcagc='rubocop --auto-gen-config' # Run rubocop autogen config
# ERB Lint
alias erbl='erblint --lint-all --config .erb-lint.yml' # ERB Lint autocorrect
alias erblac='erblint --lint-all --config .erb-lint.yml --autocorrect' # ERB Lint autocorrect
# Slim Lint
alias sl='slim-lint app/**/*.slim --config .slim-lint.yml' # Run Slim lint
# Rails Setup Helpers (make into generators?)
# Devise Setup (Add a name for the user model at the end)
alias sud='rails generate devise:install && rails generate devise'
# Devise with Bootstrap Setup (Still need to add to application.css)
alias sudbs='rails generate bootstrap:install static && rails g devise:views:locale en && rails g devise:views:bootstrap_templates'
# ----------------------
# ----------------------
# This is often needed after switching ruby versions.
alias rvmlid='rvm use ruby --latest --install --default' # RVM latest stable ruby install as default
alias rvmdu='rvm use --default' # RVM Default Use, sets the default ruby version (IE: rvmdu 2.4.0)
alias rvmudi='rvm use --default --install' # RVM Default Use, sets the default ruby version (IE: rvmdu 2.4.0)
alias bs='gem install bundle && bundle install' # Bundle Setup, adds the bundle gem and updates
alias bsu='gem install bundle && bundle update && bundle install' # Bundle Setup, adds the bundle gem and updates
# ----------------------
# Postgres
# ----------------------
alias pgr="sudo service postgresql stop && sudo service postgresql start"
# Postgres Setup:
alias c9pgr="pg_restore --verbose --clean --no-acl --no-owner -h $IP -U ubuntu -d"
# Cloud9 pg_restore, just add database name and dump file name
# ----------------------
# ----------------------
alias msr="sudo /etc/init.d/mysql stop && sudo /etc/init.d/mysql start" # Restart MySQL server
# ----------------------
# (NodeJS)
# ----------------------
alias bb="brunch build"
alias bbp="brunch build --production"
# ----------------------
# Git Aliases (V1.X)
# ----------------------
alias gic='git init && git add -A && git commit -m "Initial commit"' # Git initial commit
alias ga='git add'
alias gaa='git add -A' # Stage All (New/Modified/Deleted)
alias gaad='git add -A && git diff --staged' # Stage All and check diffs
alias gad='git add .' # ... Exclude Deleted
alias gan='git add -u' # ... Exclude New
alias gac='git add -A && git commit -m' # Add all and commit
alias gb='git branch'
# - Extended to incldue staging and develop branches
alias gbd='git branch -d' # Safer Delete
alias gbda='git branch | grep -v "master\|staging\|develop" | xargs git branch -d' # Safer Delete
alias gbD='git branch -D' # Risky Delete
alias gbDa='git branch | grep -v "master\|staging\|develop" | xargs git branch -D' # Risky Delete
alias gbr='git branch -m' # Git Branch Rename
alias gcm='git commit -m'
alias gco='git checkout'
alias gcob='git checkout -b'
alias gcom='git checkout master'
alias gcos='git checkout staging'
alias gcod='git checkout develop' # Checkout development branch
alias gcodev='git checkout development' # Checkout development branch
alias gd='git diff'
alias gda='git diff HEAD'
alias gds='git diff --staged'
alias gf='git fetch'
alias gi='git init'
alias gl='git log'
alias glg='git log --graph --oneline --decorate --all'
alias gld='git log --pretty=format:"%h %ad %s" --date=short --all'
alias gm='git merge --no-ff'
alias gmff='git merge'
alias gp='git pull'
alias gpm='git push' # Push to Github
alias gpo='git push origin' # Push to Github (V2)
alias gphm='git push heroku master' # Push to Heroku
alias gphp='git push heroku-production master' # Push to Heroku (production)
alias gphs='git push heroku-staging staging:master' # Push to Heroku (staging)
alias grbc="git rebase --continue"
alias grbac="git add -A && git rebase --continue"
alias grbrc="git reset && git rebase --continue"
alias grHa="git add -A && git reset --hard HEAD" # Git Reset Hard All, Add all and reset hard to HEAD
alias grhH="git reset --hard HEAD" # Git Reset Hard All, Add all and reset hard to HEAD
alias grs="git reset HEAD" # Git Remove From Staging
alias grs="git reset HEAD" # Git Remove From Staging
alias guc='git reset HEAD^ && gss' # Git Undo Commit; unstage, undo commit, and show status
alias gss='git status -s'
alias gsss='git status'
alias gst='git stash'
alias gstl='git stash list'
alias gstp='git stash pop'
alias gstd='git stash drop'
alias gtd='git update-index --assume-unchanged' # Git Track Disable; disable tracking of changes
alias gte='git update-index --no-assume-unchanged' # Git Track Enabled; enable tracking of changes
# Heroku
alias hf="heroku update || heroku help" # Heroku Fix; Fixes most heroku issues
alias huf="wget -qO- | sh" # Heroku Update Force, updates forcefully
alias hai="heroku apps:info" # Get info on current Heroku App
alias hgra="heroku git:remote -a" # Heroku Add Git Remote, adds git remote for app
alias hrm='heroku run --remote heroku-production'
alias hrs='heroku run --remote heroku-staging'
alias hrdm="heroku run rake db:migrate"
alias hrdhr="heroku run 'rake db:drop db:create db:migrate db:schema:dump db:setup'"
alias hrdbm0='rake db:migrate VERSION=0'
alias hl="heroku logs" # Logs
alias hlg="heroku logs -n 10000 | grep" # Logs w/ grep
alias hlt="heroku logs -t"
alias hltg="heroku logs -t -n 10000 | grep" # Logs Tail w/ grep
alias hld="heroku logs -n 10000 > tmp/heroku-logs.log" # Heroku logs dump, dumps heroku logs to tmp file
alias rap="RAILS_ENV=production rake assets:precompile" # Rails assets precompile
alias hpa="rap && gac 'Precompile assets for Heroku' " # Heroku Precompile Assets and Commit
# ----------------------
# ----------------------
alias est='expo start --tunnel'
# ----------------------
# Git Flow
# ----------------------
# Safely clean up merged branches before fetching and checkout of develop
alias gffcod='gbda; git fetch && git checkout develop'
alias gffs='gffcod && gcos && git flow feature start'
alias gfrb='gffcod && git pull origin develop && git rebase -i develop'
alias gfrspec='xvfb-run -a bundle exec rspec'
# ----------------------
# Misc
# ----------------------
alias gfrspec='xvfb-run -a bundle exec rspec'
# ----------------------
# Alias Functions
# ----------------------
bstcs () {
# Bootstrap themed controller scaffold
rails g scaffold_controller $1 && rails g bootstrap:themed $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment