Parker Smith Software

 
 

Improve your workflow with aliases

By Brian Webb

6 Nov 2008

When working with the command line there are a lot of different commands that you may use, git add, git commit, mysql etc. So why not improve your workflow and speed by making an alias or two to do those commands. This example assumes that you are working on a Unix based operating system and using bash as your shell. This is the case in our development environment on Mac OS X. The default shell in OS X is bash, so we'll stick these alias lines in a file names .bash_profile that sits in your home directory. So for me this is /Users/brian/.bash_profile. Here are the aliases:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

alias memcached_start='/opt/local/bin/memcached -d -m 64 -u www -l 127.0.0.1 -p 11211'
alias memcached_stop='sudo killall memcached'

#ssh
alias connect='ssh -p 29876 '

#top
alias tu='top -o cpu' #cpu
alias tm='top -o vsize' #memory

#git
alias gb='git branch'
alias gba='git branch -a'
alias gcv='git commit -v'
alias gcm='git commit -m'
alias gd='git diff | mate'
alias gl='git pull'
alias gp='git push'
alias ga='git add'
alias gaa='git add . && echo "git added ."'
alias gpa='echo "running: git push --all" && git push --all'
alias gst='git status'

#textmate
alias et='mate .&'
alias ett='mate app config lib db public test vendor/plugins &'

#ruby
alias att='autotest'

#mysql
alias mysql='/usr/local/bin/mysql/mysql'
alias mysqladmin='/usr/local/bin/mysql/mysqladmin'
alias mysqlstart='sudo /usr/local/bin/mysql/mysqld_safe &'
alias mysqlstop='/usr/local/bin/mysql/mysqladmin -u root -p shutdown'
alias sql='mysql -u root -p'

After editing the file you can either quit and restart your terminal, or you can run:

1
2

source ~/.bash_profile

Now you have all these really cool alias commands that make your workflow really fast. For example, say you have been working on some code and need to add, commit, and push the code to the origin server. Use the aliases....

1
2
3
4

gaa
gcm "added foo bar feature"
gpa

No Spam: 4 + 7 =