Skip to content

Linux Bash script is wrong. FIX HERE! #93

@ghost

Description

The util/install_linux.sh script is badly written and does not work properly.
Here is the fixed script:

#!/bin/bash

# if the folder does not exist, create the folder
mkdir -p $HOME/.local/share/fonts/monaspace

# remove all fonts from ~/.local/share/fonts that start with "Monaspace"
rm -rf $HOME/.local/share/fonts/monaspace/Monaspace*

# copy all fonts from ./otf to ~/.local/share/fonts
cp $HOME/monaspace/fonts/otf/* $HOME/.local/share/fonts/monaspace

# copy variable fonts from ./variable to ~/.local/share/fonts
cp $HOME/monaspace/fonts/variable/* $HOME/.local/share/fonts/monaspace

# Build font information caches
fc-cache -f

Changes

  1. Now, if the folder fonts does not exist, create the folder inside $HOME/.local/share/
  2. The script now creates a folder called monaspace to keep the files there, keeping the fonts folder cleaner.
  3. Now to copy the files, the direction of the folder is specified to avoid the cp: cannot stat error
  4. Now use $HOME to make it easier for the user to read the script.

Particularities

We assume that the script is executed from the home folder of your system. Otherwise, the script will fail. The script expects the folder monaspace to be in your $HOME folder.

Observations

If you want, you can delete the follow command:

# remove all fonts from ~/.local/share/fonts that start with "Monaspace".
rm -rf $HOME/.local/share/fonts/monaspace/Monaspace*

And use cp -u instead. If you want to copy the file only if it is newer than the destination, invoke the command with the -u option, like this:

# copy all fonts from ./otf to ~/.local/share/fonts
cp -u $HOME/monaspace/fonts/otf/* $HOME/.local/share/fonts/monaspace

# copy variable fonts from ./variable to ~/.local/share/fonts
cp -u $HOME/monaspace/fonts/variable/* $HOME/.local/share/fonts/monaspace

And beyond

A script could be written to download and install automatically with a single .sh file.

#!/bin/bash

# download monaspace from github
git clone https://github.com/githubnext/monaspace.git

# create folders
mkdir -p $HOME/.local/share/fonts/monaspace

# remove all fonts from ~/.local/share/fonts that start with "Monaspace"
rm -rf $HOME/.local/share/fonts/monaspace/Monaspace*

# copy all fonts from ./otf to ~/.local/share/fonts
cp $HOME/monaspace/fonts/otf/* $HOME/.local/share/fonts/monaspace

# copy variable fonts from ./variable to ~/.local/share/fonts
cp $HOME/monaspace/fonts/variable/* $HOME/.local/share/fonts/monaspace

# Build font information caches
fc-cache -f

# after the install, delete the monaspace folder from your home folder
rm -rf ./monaspace

¡Un saludo!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions