-
Notifications
You must be signed in to change notification settings - Fork 1
/
install-alacritty.sh
executable file
·77 lines (67 loc) · 1.87 KB
/
install-alacritty.sh
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh
# templated by http://qiita.com/blackenedgold/items/c9e60e089974392878c8
usage() {
cat <<HELP
NAME:
$0 -- install alacritty
SYNOPSIS:
$0 [--force] [--verbose] VERSION
$0 [-h|--help]
DESCRIPTION:
{description here}
--force Skip version check and force install
-h --help Print this help.
--verbose Enables verbose mode.
HELP
}
alacritty_version() {
alacritty --version | sed 's/(.*)//' | grep -Eo '[0-9.]+'
}
main() {
SCRIPT_DIR="$(cd $(dirname "$0"); pwd)"
: ${PREFIX:=~/compile}
force=false
while [ $# -gt 0 ]; do
case "$1" in
--force) force=true; shift ;;
--help) usage; exit 0;;
--verbose) set -x; shift;;
--) shift; break;;
-*)
OPTIND=1
while getopts h OPT "$1"; do
case "$OPT" in
h) usage; exit 0;;
esac
done
shift
;;
*) break;;
esac
done
if [ $# != 1 ]; then
usage
exit 1
fi
VERSION="$1"
echo "current version = $(alacritty_version) , required version = ${VERSION}"
if "$force" || [ "$(alacritty_version)" != "${VERSION}" ]; then
echo "start installing $VERSION"
if ! [ -d "$PREFIX/alacritty/" ]; then
(
mkdir -p "$PREFIX"
cd "$PREFIX"
git clone https://github.com/jwilm/alacritty.git
)
fi
cd "$PREFIX/alacritty/"
git fetch -a
git checkout "v${VERSION}"
cargo install -f cargo-deb
cargo deb --install --manifest-path=alacritty/Cargo.toml -- --no-default-features --features=wayland
echo "installation of alacritty ${VERSION} done"
else
echo "alacritty is up to date. do nothing."
fi
}
main "$@"