feat(font): remove install as user requirement on Windows

This commit is contained in:
Jan De Dobbeleer 2024-07-01 12:01:25 +02:00 committed by Jan De Dobbeleer
parent e0e26f1400
commit 1855a786dc
2 changed files with 6 additions and 29 deletions

View file

@ -11,8 +11,6 @@ import (
)
var (
user bool
// fontCmd can work with fonts
fontCmd = &cobra.Command{
Use: "font [install|configure]",
@ -43,21 +41,8 @@ This command is used to install fonts and configure the font in your terminal.
terminal.Init(env.Shell())
// Windows users need to specify the --user flag if they want to install the font as user
// If the user does not specify the --user flag, the font will be installed as a system font
// and therefore we need to be administrator
system := env.Root()
if env.GOOS() == platform.WINDOWS && !user && !system {
fmt.Println(`
You need to be administrator to install a font as system font.
You can either run this command as administrator or specify the --user flag to install the font for your user only:
font.Run(fontName, env.Root())
oh-my-posh font install --user
`)
return
}
font.Run(fontName, system)
return
case "configure":
fmt.Println("not implemented")
@ -70,5 +55,4 @@ This command is used to install fonts and configure the font in your terminal.
func init() {
RootCmd.AddCommand(fontCmd)
fontCmd.Flags().BoolVar(&user, "user", false, "install font as user")
}

View file

@ -23,16 +23,10 @@ To see the icons displayed in Oh My Posh, **install** a [Nerd Font][nerdfonts],
}>
<TabItem value="oh-my-posh">
Oh My Posh has a CLI to help you select and install a [Nerd Font][nerdfonts] (beta):
Oh My Posh has a CLI to help you select and install a [Nerd Font][nerdfonts]:
:::caution Windows
This command is best executed as admin so that fonts are installed system wide.
In case you have no admin rights, you can install the fonts by adding the `--user` flag.
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.
:::info
When running as root/administrator, the fonts will be installed system-wide.
When running as a regular user, the fonts will be installed in the user's font directory.
:::
@ -49,12 +43,11 @@ oh-my-posh font install meslo
</TabItem>
<TabItem value="homebrew">
If you're using Homebrew, you can install Nerd Fonts directly:
If you're using Homebrew, you can search for and install Nerd Fonts directly:
```bash
brew search nerd-font # Search for font packages
brew search nerd-font
# EXAMPLE: Install the NF version of Fira Code
brew install --cask font-fira-code-nerd-font
```