view .bash_mozilla @ 630:6e6a2adaa9f6

file modes
author Jeff Hammel <k0scist@gmail.com>
date Thu, 20 Feb 2014 12:11:17 -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

}