view .bash_mozilla @ 573:1e1db18fb7fa

STUB: bin/setup-X.sh
author Jeff Hammel <k0scist@gmail.com>
date Thu, 16 Jan 2014 16:32:52 -0800
parents 8741c4241a4c
children
line wrap: on
line source

#!/bin/bash

# mozilla-specific bash customizations

# mozilla env vairables
export MOZCONFIG=~/mozilla/mozconfigs/mozconfig
export MOZSOURCE=~/mozilla/src/mozilla-central
export MOZOBJ=~/mozilla/src/obj-browser
unsetmozenv() {
unset MOZCONFIG
unset MOZSOURCE
unset MOZOBJ
env | sort
}
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}
    export PS1="[${name}]${PS1}"

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

}