How to build a custom command with options

Solution 1:

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.