Last active
April 26, 2024 07:36
-
-
Save koiralakiran1/ddb3872adfea6a80c554fc27207ba868 to your computer and use it in GitHub Desktop.
Install fonts on linux distros systemwide
This file contains 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
#!/bin/env bash | |
# Installs fonts system wide. Default install directory is /usr/share/fonts/my-installed-fonts. | |
# All fonts in /usr/share/fonts directory are recursively added by fc-cache, so we can install in custom directory | |
# Why this? | |
# Because some font installers like font-manager installs fonts only for current user | |
# i.e. in ~/.local/share/fonts which some applications like vscode didn't detect. | |
# Usage | |
# install-fonts a.ttf b.ttf c.ttf | |
set -e | |
YELLOW='\033[1;33m' | |
GREEN='\033[0;32m' | |
NOCOLOR='\033[0m' | |
INSTALL_DIR=/usr/share/fonts/my-installed-fonts | |
FONTS_TO_INSTALL=$@ | |
#echo -e "INFO :::${YELLOW} Creating directory ${INSTALL_DIR}, if not present i.e. with -p option ${NOCOLOR}\n" | |
sudo mkdir -p $INSTALL_DIR | |
#echo -e "INFO :::${YELLOW} Moving \"${FONTS_TO_INSTALL}\" to ${INSTALL_DIR} ${NOCOLOR}\n" | |
sudo cp $FONTS_TO_INSTALL $INSTALL_DIR | |
#echo -e "INFO :::${YELLOW} Re-evaluating font cache. i.e. fc-cache -fv ${NOCOLOR}\n" | |
fc-cache -fv | |
echo -e "${GREEN} Fonts installed. ${NOCOLOR}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment