linuxvisual-studio-codefontslinux-mintoh-my-posh

How to install font for oh-my-posh in Linux VS Code bash?


I installed oh-my-posh, and got MesloLGLDZ Nerd Font installed separately (had to, because the omp font installer kept giving an error). That font is part of my system now. It appears in system fonts.

My system terminal is looking great, but in VS Code, it's missing the symbols from the font. Just showing rectangles.

System enter image description here

VS Code enter image description here

I have only seen instructions for Windows, but I'm on Mint. I have the default theme I suppose, since I didn't change that, and I want to keep that.

In the system terminal, I did it by going into settings for the terminal. But in VS Code, how can I connect my new font with omp? I tried changing the terminal font to "terminal.integrated.fontFamily": "MesloLGLDZ Nerd Font Mono" in VS Code's settings.json, but that just messed up the font and didn't add the symbols as hoped.


Solution

  • I was able to get it all working in Linux, VS Code: enter image description here

    1. [VS Code][terminal] Install Oh my Posh:
      sudo wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -O /usr/local/bin/oh-my-posh
      sudo chmod +x /usr/local/bin/oh-my-posh
      
    2. [VS Code][terminal] Download the themes:
      mkdir ~/.poshthemes
      wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/themes.zip -O ~/.poshthemes/themes.zip
      unzip ~/.poshthemes/themes.zip -d ~/.poshthemes
      chmod u+rw ~/.poshthemes/*.json
      rm ~/.poshthemes/themes.zip
    3. [VS Code][terminal] Install the font:
      sudo apt install fontconfig
      cd ~
      wget https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/Meslo.zip
      mkdir -p .local/share/fonts
      unzip Meslo.zip -d .local/share/fonts
      cd .local/share/fonts
      rm Windows
      cd ~
      rm Meslo.zip
      fc-cache -fv
    4. [VS Code] [settings.json] Fix the font:
      "terminal.integrated.fontFamily": "MesloLGLDZ Nerd Font Mono",
      "terminal.integrated.fontSize": 12,
    5. [VS Code][terminal] Append to bash rc: nano ~/.bashrc
    6. [Files] Select a theme: they are in /home/toddmo/.poshthemes for your user.
    7. [VS Code][terminal][nano] Make omp permentant:
      #oh-my-posh
      eval "$(oh-my-posh --init --shell bash --config /home/toddmo/.poshthemes/atomic.omp.json)"
    8. [VS Code][terminal][nano] Save Changes: CTRL+X, Y, ENTER
    9. Close Terminal
    10. Reopen Terminal: CTRL+SHIFT+`

    If you want to change the icons in omp, see the nerd font icon list. They will show codes like /f007. In omp theme files, they will show a icon code like \uF817. So, take the last four digits of the nerd font and put it after \u, example, \uf007.