-
Notifications
You must be signed in to change notification settings - Fork 0
/
cthanybar
executable file
·40 lines (35 loc) · 1.35 KB
/
cthanybar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash
[ -n "$CTH_VERBOSE" ] && set -x
# shellcheck disable=SC2039
set -E
# Announces build state via Anybar's coloured dot in the menu bar
# Copyright 2016- tobylane. Licensed under the MIT licence found in LICENSE.txt or online
# Requires Anybar: brew cask install anybar or https://github.com/tonsky/AnyBar
# Usage: Run, with cthupdate parameters, manually or with launchctl with the following:
# /usr/local/bin/bash -c "(cd $HOME/Downloads/CorsixTH && build_files/cthanybar)"
ANYBAR_PORT=1739 open -a Anybar # Different port, open and direct Anybar
anybar () { printf %s "$1" | nc -4u -w0 localhost "${2:-1739}"; }
cd "$(git rev-parse --show-toplevel)"
anybar question # In progress
output=$(build_files/cthupdate "$@")
err=$?
set -e
if [ "$output" = 'No new changes.' ]
then anybar purple # No changes
elif [ -z "$*" ] && ! git diff --name-only 'HEAD@{1}' HEAD | grep -qi -e cmake -e Src
then anybar blue # Lua changes only
elif [ "$err" != "0" ]
then # Git/cmake/xcode/bash failed, narrow it down
if ! git pull --ff-only; then anybar yellow
elif ! build_files/cthupdate cmake; then anybar orange
elif ! build_files/cthupdate make; then anybar red
else anybar black
fi
elif [ "$err" = "0" ]
then
if git describe --tags --contains 'HEAD@{1}' > /dev/null 2>&1
then anybar cyan # Release
else
anybar green # Successful new build
fi
fi