annotate .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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
551
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 #!/bin/bash
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 # mozilla-specific bash customizations
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 MOZCONFIGS=${HOME}/mozilla/mozconfigs
554
8ef38b16dcb9 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 553
diff changeset
6 MOZSRC=${HOME}/mozilla/src
551
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 mozconfig() {
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 if [ ! -e ${MOZCONFIGS} ]
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11 then
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12 echo "MOZCONFIGS directory ${MOZCONFIGS} does not exist"
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13 return 1
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14 fi
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
15
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
16 if [[ "$#" == "0" ]]
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17 then
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
18 # list the available configs
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
19 ls -1 ${MOZCONFIGS} | sort
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
20 elif [[ "$#" == "1" ]]
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
21 then
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
22 # activate the chosen mozconfig
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
23 name=$1
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
24 for _MOZCONFIG in "${MOZCONFIGS}/${name}" "${MOZCONFIGS}/mozconfig.${name}"
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
25 do
553
752e5eea7ea8 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 551
diff changeset
26 if [[ -e "${_MOZCONFIG}" ]]
752e5eea7ea8 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 551
diff changeset
27 then
752e5eea7ea8 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 551
diff changeset
28 break
752e5eea7ea8 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 551
diff changeset
29 fi
551
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
30 done
553
752e5eea7ea8 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 551
diff changeset
31 if [[ ! -e "${_MOZCONFIG}" ]]
752e5eea7ea8 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 551
diff changeset
32 then
752e5eea7ea8 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 551
diff changeset
33 echo "MOZCONFIG ${name} not found"
752e5eea7ea8 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 551
diff changeset
34 return 1
752e5eea7ea8 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 551
diff changeset
35 fi
554
8ef38b16dcb9 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 553
diff changeset
36
8ef38b16dcb9 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 553
diff changeset
37 # get name of file
8ef38b16dcb9 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 553
diff changeset
38 filename=$(basename $_MOZCONFIG)
8ef38b16dcb9 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 553
diff changeset
39 if [[ "${filename}" == *.* ]]
8ef38b16dcb9 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 553
diff changeset
40 then
8ef38b16dcb9 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 553
diff changeset
41 name="${filename##*.}"
8ef38b16dcb9 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 553
diff changeset
42 prefix="${name}"
8ef38b16dcb9 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 553
diff changeset
43 else
8ef38b16dcb9 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 553
diff changeset
44 name=".default."
8ef38b16dcb9 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 553
diff changeset
45 prefix="obj"
8ef38b16dcb9 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 553
diff changeset
46 fi
8ef38b16dcb9 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 553
diff changeset
47
8ef38b16dcb9 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 553
diff changeset
48 # set environment variables
8ef38b16dcb9 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 553
diff changeset
49 export MOZCONFIG=${_MOZCONFIG}
8ef38b16dcb9 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 553
diff changeset
50
8ef38b16dcb9 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 553
diff changeset
51 # print info
8ef38b16dcb9 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 553
diff changeset
52 echo "Using MOZCONFIG=${MOZCONFIG} [${name}] :"
8ef38b16dcb9 .bash_mozilla
Jeff Hammel <jhammel@mozilla.com>
parents: 553
diff changeset
53 cat "${MOZCONFIG}"
551
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
54 else
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
55 # print usage
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
56 echo "Usage: mozconfig <configname>"
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
57 return 1
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
58 fi
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
59
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
60 }