Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.