Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to make a command on my Mac to do the following:

git add .
git commit -m CUSTOM_COMMEND_BY_COMMAND
git push
cap deploy

I seem to be calling those very often. I was wondering what's the best way to build a command such as:

qwik_dply -m "fixed a big"
share|improve this question
up vote 4 down vote accepted

You could do this using a custom bash function. Add that to your .bash_profile:

function qwik_dply {
    local msg=$1
    if [ -z "$msg" ] ; then
        msg="No message"
    fi
    git add .
    git commit -m "$msg"
    git push
    cap deploy
}

Call from bash using qwik_dply "Some text"


Alternatively, make it a proper script:

#!/usr/bin/env bash
msg=$1
if [ -z "$msg" ] ; then
    echo "Usage: qwik_dply <message>"
    exit 1
fi
git add .
git commit -m "$msg"
git push
cap deploy

Save as qwik_dply.sh, run chmod ugo+x qwik_dply.sh and mv it to /usr/bin or any other directory on your $PATH.

Then, run using qwik_dply.sh "Some message". You could remove the file name extension, of course.

share|improve this answer
    
Awesome. Well put. thanks – Tam May 15 '11 at 18:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .