mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-02 05:41:10 -08:00
feat(font): install system wide as root on Linux
This commit is contained in:
parent
9122a8974b
commit
89beb8db68
|
@ -10,15 +10,23 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
// FontsDir denotes the path to the user's fonts directory on Unix-like systems.
|
||||
var FontsDir = path.Join(os.Getenv("HOME"), "/.local/share/fonts")
|
||||
var (
|
||||
fontsDir = path.Join(os.Getenv("HOME"), "/.local/share/fonts")
|
||||
systemFontsDir = "/usr/share/fonts"
|
||||
)
|
||||
|
||||
func install(font *Font, _ bool) error {
|
||||
// If we're running as root, install the font system-wide.
|
||||
targetDir := fontsDir
|
||||
if os.Geteuid() == 0 {
|
||||
targetDir = systemFontsDir
|
||||
}
|
||||
|
||||
// On Linux, fontconfig can understand subdirectories. So, to keep the
|
||||
// font directory clean, install all font files for a particular font
|
||||
// family into a subdirectory named after the family (with hyphens instead
|
||||
// of spaces).
|
||||
fullPath := path.Join(FontsDir,
|
||||
fullPath := path.Join(targetDir,
|
||||
strings.ToLower(strings.ReplaceAll(font.Family, " ", "-")),
|
||||
path.Base(font.FileName))
|
||||
|
||||
|
|
|
@ -33,6 +33,11 @@ In case you have no admin rights, you can install the fonts by adding the `--use
|
|||
Do know this can have side-effects when using certain applications.
|
||||
:::
|
||||
|
||||
:::info Linux
|
||||
On Linux, when running as root, the fonts will be installed system-wide.
|
||||
When running as a regular user, the fonts will be installed in the user's font directory.
|
||||
:::
|
||||
|
||||
```bash
|
||||
oh-my-posh font install
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue