READMD.md
· 706 B · Markdown
Исходник
# Ubuntu Sans Nerd Font Setup
A lightweight script to automatically fetch and install the latest **Ubuntu Sans Nerd Font** for Ubuntu Desktop.
## Quick Install
Run the following command in your terminal:
```bash
bash -c "$(curl -fsSL https://opengist.rmrf.online/weehong/2de15ba0106a475fa41215159203a63b/raw/HEAD/install_font.sh)"
```
## Overview
* **Always Latest:** Dynamically pulls the newest release from the official Nerd Fonts GitHub.
* **No Sudo Needed:** Installs safely to your local user directory (`~/.local/share/fonts/UbuntuSans`).
* **Ready to Use:** Automatically updates the font cache (`fc-cache`) so fonts are available immediately.
* **Dependencies:** Requires `curl` and `unzip`.
Ubuntu Sans Nerd Font Setup
A lightweight script to automatically fetch and install the latest Ubuntu Sans Nerd Font for Ubuntu Desktop.
Quick Install
Run the following command in your terminal:
bash -c "$(curl -fsSL https://opengist.rmrf.online/weehong/2de15ba0106a475fa41215159203a63b/raw/HEAD/install_font.sh)"
Overview
- Always Latest: Dynamically pulls the newest release from the official Nerd Fonts GitHub.
- No Sudo Needed: Installs safely to your local user directory (
~/.local/share/fonts/UbuntuSans). - Ready to Use: Automatically updates the font cache (
fc-cache) so fonts are available immediately. - Dependencies: Requires
curlandunzip.
install_font.sh
· 1.7 KiB · Bash
Исходник
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
FONT_NAME="UbuntuSans"
FONT_ZIP="${FONT_NAME}.zip"
# Simplified directory: removed the "NerdFonts" subfolder
FONT_DIR="$HOME/.local/share/fonts/${FONT_NAME}"
TMP_DIR=$(mktemp -d)
echo "Searching for the latest release of $FONT_NAME Nerd Font..."
# Use GitHub API to find the latest release download URL for UbuntuSans.zip
DOWNLOAD_URL=$(curl -s https://api.github.com/repos/ryanoasis/nerd-fonts/releases/latest \
| grep "browser_download_url.*${FONT_ZIP}" \
| cut -d '"' -f 4)
if [ -z "$DOWNLOAD_URL" ]; then
echo "Error: Could not find the download URL for $FONT_NAME. Check your internet connection or GitHub API limits."
rm -rf "$TMP_DIR"
exit 1
fi
echo "Latest version found!"
echo "Downloading from: $DOWNLOAD_URL"
# Download the zip file to the temporary directory
curl -L -q "$DOWNLOAD_URL" -o "$TMP_DIR/$FONT_ZIP"
echo "Extracting fonts..."
# Ensure unzip is installed (will fail gracefully if not)
if ! command -v unzip &> /dev/null; then
echo "Error: 'unzip' is not installed. Please install it using 'sudo apt install unzip' and try again."
rm -rf "$TMP_DIR"
exit 1
fi
unzip -q -o "$TMP_DIR/$FONT_ZIP" -d "$TMP_DIR/extracted"
echo "Installing fonts to $FONT_DIR..."
# Create the simplified font directory if it doesn't exist
mkdir -p "$FONT_DIR"
# Move only the TrueType (.ttf) or OpenType (.otf) files to the fonts directory
find "$TMP_DIR/extracted" -name '*.[ot]tf' -type f -exec cp {} "$FONT_DIR/" \;
echo "Updating the system font cache..."
fc-cache -f "$FONT_DIR"
echo "Cleaning up temporary files..."
rm -rf "$TMP_DIR"
echo "Done! $FONT_NAME Nerd Font has been successfully installed."
| 1 | #!/bin/bash |
| 2 | |
| 3 | # Exit immediately if a command exits with a non-zero status |
| 4 | set -e |
| 5 | |
| 6 | FONT_NAME="UbuntuSans" |
| 7 | FONT_ZIP="${FONT_NAME}.zip" |
| 8 | # Simplified directory: removed the "NerdFonts" subfolder |
| 9 | FONT_DIR="$HOME/.local/share/fonts/${FONT_NAME}" |
| 10 | TMP_DIR=$(mktemp -d) |
| 11 | |
| 12 | echo "Searching for the latest release of $FONT_NAME Nerd Font..." |
| 13 | |
| 14 | # Use GitHub API to find the latest release download URL for UbuntuSans.zip |
| 15 | DOWNLOAD_URL=$(curl -s https://api.github.com/repos/ryanoasis/nerd-fonts/releases/latest \ |
| 16 | | grep "browser_download_url.*${FONT_ZIP}" \ |
| 17 | | cut -d '"' -f 4) |
| 18 | |
| 19 | if [ -z "$DOWNLOAD_URL" ]; then |
| 20 | echo "Error: Could not find the download URL for $FONT_NAME. Check your internet connection or GitHub API limits." |
| 21 | rm -rf "$TMP_DIR" |
| 22 | exit 1 |
| 23 | fi |
| 24 | |
| 25 | echo "Latest version found!" |
| 26 | echo "Downloading from: $DOWNLOAD_URL" |
| 27 | |
| 28 | # Download the zip file to the temporary directory |
| 29 | curl -L -q "$DOWNLOAD_URL" -o "$TMP_DIR/$FONT_ZIP" |
| 30 | |
| 31 | echo "Extracting fonts..." |
| 32 | # Ensure unzip is installed (will fail gracefully if not) |
| 33 | if ! command -v unzip &> /dev/null; then |
| 34 | echo "Error: 'unzip' is not installed. Please install it using 'sudo apt install unzip' and try again." |
| 35 | rm -rf "$TMP_DIR" |
| 36 | exit 1 |
| 37 | fi |
| 38 | |
| 39 | unzip -q -o "$TMP_DIR/$FONT_ZIP" -d "$TMP_DIR/extracted" |
| 40 | |
| 41 | echo "Installing fonts to $FONT_DIR..." |
| 42 | # Create the simplified font directory if it doesn't exist |
| 43 | mkdir -p "$FONT_DIR" |
| 44 | |
| 45 | # Move only the TrueType (.ttf) or OpenType (.otf) files to the fonts directory |
| 46 | find "$TMP_DIR/extracted" -name '*.[ot]tf' -type f -exec cp {} "$FONT_DIR/" \; |
| 47 | |
| 48 | echo "Updating the system font cache..." |
| 49 | fc-cache -f "$FONT_DIR" |
| 50 | |
| 51 | echo "Cleaning up temporary files..." |
| 52 | rm -rf "$TMP_DIR" |
| 53 | |
| 54 | echo "Done! $FONT_NAME Nerd Font has been successfully installed." |