view .bash_mozilla @ 554:8ef38b16dcb9

.bash_mozilla
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 19 Nov 2013 14:04:49 -0800
parents 752e5eea7ea8
children f98fe4362c84
line wrap: on
line source

#!/bin/bash

# mozilla-specific bash customizations

MOZCONFIGS=${HOME}/mozilla/mozconfigs
MOZSRC=${HOME}/mozilla/src

mozconfig() {

if [ ! -e ${MOZCONFIGS} ]
then
    echo "MOZCONFIGS directory ${MOZCONFIGS} does not exist"
    return 1
fi

if [[ "$#" == "0" ]]
then
    # list the available configs
    ls -1 ${MOZCONFIGS} | sort
elif [[ "$#" == "1" ]]
then
    # activate the chosen mozconfig
    name=$1
    for _MOZCONFIG in "${MOZCONFIGS}/${name}" "${MOZCONFIGS}/mozconfig.${name}"
    do
        if [[ -e "${_MOZCONFIG}" ]]
        then
            break
        fi
    done
    if [[ ! -e "${_MOZCONFIG}" ]]
    then
        echo "MOZCONFIG ${name} not found"
        return 1
    fi

    # get name of file
    filename=$(basename $_MOZCONFIG)
    if [[ "${filename}" == *.* ]]
    then
        name="${filename##*.}"
        prefix="${name}"
    else
        name=".default."
        prefix="obj"
    fi

    # set environment variables
    export MOZCONFIG=${_MOZCONFIG}

    # print info
    echo "Using MOZCONFIG=${MOZCONFIG} [${name}] :"
    cat "${MOZCONFIG}"
else
    # print usage
    echo "Usage: mozconfig <configname>"
    return 1
fi

}