-
Notifications
You must be signed in to change notification settings - Fork 0
/
nerdfont.sh
executable file
·37 lines (32 loc) · 949 Bytes
/
nerdfont.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
#!/usr/bin/env bash
# installs nerd fonts
# @example dotfiles_nerdfont CascadiaCode
function dotfiles_nerdfont {
# click here to see all available fonts
local url='https://github.com/ryanoasis/nerd-fonts/releases/latest'
local name="$1"
# only on Linux
if [[ $(uname -s) != 'Linux' ]] ; then
echo 'dotfiles_nerdfont: unsupported OS'
return 1
fi
# requires an argument
if [[ -z $name ]] ; then
echo 'dotfiles_nerdfont: missing font name'
return 1
fi
# attempt to download font
if ! curl -fsSL "$url/download/$name.zip" -o "/tmp/$name.zip" ; then
echo "dotfiles_nerdfont: failed to download $name.zip"
return 1
fi
# install
# to uninstall run: rm -rf ~/.fonts/$name && fc-cache -f
[[ ! -d "${HOME}/.fonts" ]] && mkdir "${HOME}/.fonts"
unzip -qod "${HOME}/.fonts/${name}" "/tmp/$name.zip"
fc-cache -f
}
# if not sourced
if [[ ${BASH_SOURCE[0]} = "$0" ]] ; then
dotfiles_nerdfont "$@"
fi