Bash aliases and magic

I have a seperate file in my user folder named ~/.aliases. I use this to store all of my bash aliases. I use aliases a lot and add new ones regularly so I created a bash function to add new aliases on the fly.

addalias() {
  echo 'alias '$1'="'$2'"' >> ~/.aliases
  source ~/.aliases
}


Now you can add an alias from the terminal which will be available to the current session and all new sessions... shell $ addalias foo 'echo "bar"'

If I find myself using commands over and over I will create aliases shell alias g='git' alias b='bundle' alias be='bundle exec' alias bu='bundle update' alias r='bin/rails' alias rr='bin/rails routes' alias migration='bin/rails generate migration' alias migrate='bin/rails db:migrate; bin/rails db:migrate RAILS_ENV=test' alias rollback="rake db:rollback; RAILS_ENV=test rake db:rollback" alias push='git push origin HEAD' alias pr='git pull-request -c -m' alias ppr="git push origin HEAD && git pull-request -m" alias pulls='git browse -- pulls' alias prs='git pr list' pull() { git browse -- pull/'$1' } alias la='ls -a' alias ll='ls -al'

3
Joe

Get our stories delivered

From us to your inbox weekly.