Skip to content

Commit a6e7c02

Browse files
committed
initial commit of hack-linux-installer.sh script
1 parent 95024b6 commit a6e7c02

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

hack-linux-installer.sh

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/bin/sh
2+
3+
# /////////////////////////////////////////////////////////////////
4+
#
5+
# hack-linux-installer.sh
6+
# A shell script that installs the Hack fonts from repository
7+
# releases by release version number
8+
#
9+
# Copyright 2018 Christopher Simpkins
10+
# MIT License
11+
#
12+
# Usage: ./hack-linux-installer.sh [VERSION]
13+
# Format the version number as vX.XXX
14+
#
15+
# /////////////////////////////////////////////////////////////////
16+
17+
HACK_INSTALL_PATH="$HOME/.local/share/fonts"
18+
19+
if [ $# -ne 1 ]; then
20+
echo "Please include a version number argument formatted as vX.XXX"
21+
exit 1
22+
fi
23+
24+
if [ "$1" = "--help" ]; then
25+
echo "Usage: ./hack-linux-installer [VERSION]"
26+
echo "Format [VERSION] as vX.XXX for the desired release version of the fonts."
27+
exit 0
28+
fi
29+
30+
if [ ! -d "$HACK_INSTALL_PATH" ]; then
31+
echo "Unable to detect the install directory path '$HACK_INSTALL_PATH'. Please create this path and execute the script again."
32+
exit 1
33+
fi
34+
35+
HACK_VERSION="$1"
36+
HACK_DL_URL="https://github.com/source-foundry/Hack/releases/download/$HACK_VERSION/Hack-$HACK_VERSION-ttf.tar.gz"
37+
HACK_ARCHIVE_PATH="Hack-$HACK_VERSION-ttf.tar.gz"
38+
39+
# pull user requested fonts from the Hack repository releases & unpack
40+
echo " "
41+
echo "Pulling Hack $HACK_VERSION fonts from the Github repository release..."
42+
curl -L -O "$HACK_DL_URL"
43+
44+
echo " "
45+
echo "Unpacking the font files..."
46+
if [ -f "$HACK_ARCHIVE_PATH" ]; then
47+
tar -xzvf "$HACK_ARCHIVE_PATH"
48+
else
49+
echo "Unable to find the pulled archive file. Install failed."
50+
exit 1
51+
fi
52+
53+
# install
54+
if [ -d "ttf" ]; then
55+
echo " "
56+
echo "Installing the Hack fonts..."
57+
# clean up archive file
58+
rm "$HACK_ARCHIVE_PATH"
59+
60+
# move fonts to install directory
61+
echo "Installing Hack-Regular.ttf on path $HACK_INSTALL_PATH/Hack-Regular.ttf"
62+
mv ttf/Hack-Regular.ttf "$HACK_INSTALL_PATH/Hack-Regular.ttf"
63+
64+
echo "Installing Hack-Italic.ttf on path $HACK_INSTALL_PATH/Hack-Italic.ttf"
65+
mv ttf/Hack-Italic.ttf "$HACK_INSTALL_PATH/Hack-Italic.ttf"
66+
67+
echo "Installing Hack-Bold.ttf on path $HACK_INSTALL_PATH/Hack-Bold.ttf"
68+
mv ttf/Hack-Bold.ttf "$HACK_INSTALL_PATH/Hack-Bold.ttf"
69+
70+
echo "Installing Hack-BoldItalic.ttf on path $HACK_INSTALL_PATH/Hack-BoldItalic.ttf"
71+
mv ttf/Hack-BoldItalic.ttf "$HACK_INSTALL_PATH/Hack-BoldItalic.ttf"
72+
73+
echo " "
74+
echo "Cleaning up..."
75+
rm -rf ttf
76+
77+
# clear and regenerate font cache
78+
echo " "
79+
echo "Clearing and regenerating the font cache. You will see a stream of text as this occurs..."
80+
echo " "
81+
fc-cache -f -v
82+
83+
echo " "
84+
echo "Testing. You should see valid install filepaths in the output below..."
85+
fc-list | grep "Hack"
86+
87+
echo " "
88+
echo "Install of Hack $HACK_VERSION complete."
89+
exit 0
90+
else
91+
echo "Unable to identify the unpacked font directory. Install failed."
92+
exit 1
93+
fi

0 commit comments

Comments
 (0)