Created
June 16, 2020 18:32
-
-
Save hotsphink/776f9cbe0ae5bf7c2501fdf415f8ed52 to your computer and use it in GitHub Desktop.
mkgist-created gist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# `mc <suffix>`: Set MOZCONFIG to the current hg root's mozconfig.<suffix> | |
# file. If the file does not exist, will ask if you want to use the most | |
# recently edited one from a sibling directory. | |
# | |
function mc () { | |
if [ $# = 0 ]; then | |
echo "MOZCONFIG is ${MOZCONFIG:-unset}" | |
echo "available:" | |
for f in "$(hg root)/mozconfig."*; do | |
echo "${f#*mozconfig.}" | |
done | |
return | |
fi | |
local mozconfig | |
mozconfig="$(hg root)/mozconfig.$1" | |
if ! [ -f "$mozconfig" ]; then | |
echo "Warning: $mozconfig does not exist" >&2 | |
local tmp | |
tmp=$(ls -tr "$(dirname "$(hg root)")"/*/mozconfig.$1 | tail -1) | |
if [ -z "$tmp" ]; then | |
echo "No mozconfig.$1 found" >&2 | |
return | |
fi | |
echo -n "Use $tmp? (y/n) " >&2 | |
read REPLY | |
if [[ "${REPLY#y}" == "$REPLY" ]]; then | |
return | |
fi | |
echo "Copying $tmp to "$(hg root)"" | |
cp "$tmp" "$(hg root)" | |
mozconfig="$(hg root)/mozconfig.$1" | |
fi | |
export MOZCONFIG="$mozconfig" | |
echo "MOZCONFIG now $MOZCONFIG" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment