Skip to content

Commit

Permalink
feat(font): remove install as user requirement on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
JanDeDobbeleer committed Jul 4, 2024
1 parent e0e26f1 commit 1855a78
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 29 deletions.
18 changes: 1 addition & 17 deletions src/cli/font.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
)

var (
user bool

// fontCmd can work with fonts
fontCmd = &cobra.Command{
Use: "font [install|configure]",
Expand Down Expand Up @@ -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:
oh-my-posh font install --user
`)
return
}
font.Run(fontName, env.Root())

font.Run(fontName, system)
return
case "configure":
fmt.Println("not implemented")
Expand All @@ -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")
}
17 changes: 5 additions & 12 deletions website/docs/installation/fonts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
:::

Expand All @@ -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
```

Expand Down

0 comments on commit 1855a78

Please sign in to comment.