1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-15 01:34:26 +02:00

Merge pull request #2731 from jesseduffield/config-for-nerd-fonts-version

Add config for nerd fonts version
This commit is contained in:
Stefan Haller
2023-06-22 18:55:05 +02:00
committed by GitHub
6 changed files with 317 additions and 278 deletions

View File

@ -62,7 +62,8 @@ gui:
experimentalShowBranchHeads: false # visualize branch heads with (*) in commits list experimentalShowBranchHeads: false # visualize branch heads with (*) in commits list
showBottomLine: true # for hiding the bottom information line (unless it has important information to tell you) showBottomLine: true # for hiding the bottom information line (unless it has important information to tell you)
showCommandLog: true showCommandLog: true
showIcons: false showIcons: false # deprecated: use nerdFontsVersion instead
nerdFontsVersion: "" # nerd fonts version to use ("2" or "3"); empty means don't show nerd font icons
commandLogSize: 8 commandLogSize: 8
splitDiff: 'auto' # one of 'auto' | 'always' splitDiff: 'auto' # one of 'auto' | 'always'
skipRewordInEditorWarning: false # for skipping the confirmation before launching the reword editor skipRewordInEditorWarning: false # for skipping the confirmation before launching the reword editor
@ -420,9 +421,12 @@ If you are using [Nerd Fonts](https://www.nerdfonts.com), you can display icons.
```yaml ```yaml
gui: gui:
showIcons: true nerdFontsVersion: "3"
``` ```
Supported versions are "2" and "3". The deprecated config `showIcons` sets the
version to "2" for backwards compatibility.
## Keybindings ## Keybindings
For all possible keybinding options, check [Custom_Keybindings.md](https://github.com/jesseduffield/lazygit/blob/master/docs/keybindings/Custom_Keybindings.md) For all possible keybinding options, check [Custom_Keybindings.md](https://github.com/jesseduffield/lazygit/blob/master/docs/keybindings/Custom_Keybindings.md)

View File

@ -49,6 +49,7 @@ type GuiConfig struct {
ShowCommandLog bool `yaml:"showCommandLog"` ShowCommandLog bool `yaml:"showCommandLog"`
ShowBottomLine bool `yaml:"showBottomLine"` ShowBottomLine bool `yaml:"showBottomLine"`
ShowIcons bool `yaml:"showIcons"` ShowIcons bool `yaml:"showIcons"`
NerdFontsVersion string `yaml:"nerdFontsVersion"`
ShowBranchCommitHash bool `yaml:"showBranchCommitHash"` ShowBranchCommitHash bool `yaml:"showBranchCommitHash"`
ExperimentalShowBranchHeads bool `yaml:"experimentalShowBranchHeads"` ExperimentalShowBranchHeads bool `yaml:"experimentalShowBranchHeads"`
CommandLogSize int `yaml:"commandLogSize"` CommandLogSize int `yaml:"commandLogSize"`
@ -426,6 +427,7 @@ func GetDefaultConfig() *UserConfig {
ShowFileTree: true, ShowFileTree: true,
ShowRandomTip: true, ShowRandomTip: true,
ShowIcons: false, ShowIcons: false,
NerdFontsVersion: "",
ExperimentalShowBranchHeads: false, ExperimentalShowBranchHeads: false,
ShowBranchCommitHash: false, ShowBranchCommitHash: false,
CommandLogSize: 8, CommandLogSize: 8,

View File

@ -496,7 +496,11 @@ func NewGui(
gui.c = helperCommon gui.c = helperCommon
authors.SetCustomAuthors(gui.UserConfig.Gui.AuthorColors) authors.SetCustomAuthors(gui.UserConfig.Gui.AuthorColors)
icons.SetIconEnabled(gui.UserConfig.Gui.ShowIcons) if gui.UserConfig.Gui.NerdFontsVersion != "" {
icons.SetNerdFontsVersion(gui.UserConfig.Gui.NerdFontsVersion)
} else if gui.UserConfig.Gui.ShowIcons {
icons.SetNerdFontsVersion("2")
}
presentation.SetCustomBranches(gui.UserConfig.Gui.BranchColors) presentation.SetCustomBranches(gui.UserConfig.Gui.BranchColors)
gui.BackgroundRoutineMgr = &BackgroundRoutineMgr{gui: gui} gui.BackgroundRoutineMgr = &BackgroundRoutineMgr{gui: gui}

View File

@ -57,260 +57,270 @@ var nameIconMap = map[string]string{
} }
var extIconMap = map[string]string{ var extIconMap = map[string]string{
".ai": "\ue7b4", //  ".ai": "\ue7b4", // 
".android": "\ue70e", //  ".android": "\ue70e", // 
".apk": "\ue70e", //  ".apk": "\ue70e", // 
".apple": "\uf179", //  ".apple": "\uf179", // 
".avi": "\uf03d", //  ".avi": "\uf03d", // 
".avif": "\uf1c5", //  ".avif": "\uf1c5", // 
".avro": "\ue60b", //  ".avro": "\ue60b", // 
".awk": "\uf489", //  ".awk": "\uf489", // 
".bash": "\uf489", //  ".bash": "\uf489", // 
".bash_history": "\uf489", //  ".bash_history": "\uf489", // 
".bash_profile": "\uf489", //  ".bash_profile": "\uf489", // 
".bashrc": "\uf489", //  ".bashrc": "\uf489", // 
".bat": "\uf17a", //  ".bat": "\uf17a", // 
".bats": "\uf489", //  ".bats": "\uf489", // 
".bmp": "\uf1c5", //  ".bmp": "\uf1c5", // 
".bz": "\uf410", //  ".bz": "\uf410", // 
".bz2": "\uf410", //  ".bz2": "\uf410", // 
".c": "\ue61e", //  ".c": "\ue61e", // 
".c++": "\ue61d", //  ".c++": "\ue61d", // 
".cab": "\ue70f", //  ".cab": "\ue70f", // 
".cc": "\ue61d", //  ".cc": "\ue61d", // 
".cfg": "\ue615", //  ".cfg": "\ue615", // 
".class": "\ue256", //  ".class": "\ue256", // 
".clj": "\ue768", //  ".clj": "\ue768", // 
".cljs": "\ue76a", //  ".cljs": "\ue76a", // 
".cls": "\uf034", //  ".cls": "\uf034", // 
".cmd": "\ue70f", //  ".cmd": "\ue70f", // 
".coffee": "\uf0f4", //  ".coffee": "\uf0f4", // 
".conf": "\ue615", //  ".conf": "\ue615", // 
".cp": "\ue61d", //  ".cp": "\ue61d", // 
".cpio": "\uf410", //  ".cpio": "\uf410", // 
".cpp": "\ue61d", //  ".cpp": "\ue61d", // 
".cs": "\uf81a", // ".cs": "\U000f031b", // 󰌛
".csh": "\uf489", //  ".csh": "\uf489", // 
".cshtml": "\uf1fa", //  ".cshtml": "\uf1fa", // 
".csproj": "\uf81a", // ".csproj": "\U000f031b", // 󰌛
".css": "\ue749", //  ".css": "\ue749", // 
".csv": "\uf1c3", //  ".csv": "\uf1c3", // 
".csx": "\uf81a", // ".csx": "\U000f031b", // 󰌛
".cxx": "\ue61d", //  ".cxx": "\ue61d", // 
".d": "\ue7af", //  ".d": "\ue7af", // 
".dart": "\ue798", //  ".dart": "\ue798", // 
".db": "\uf1c0", //  ".db": "\uf1c0", // 
".deb": "\ue77d", //  ".deb": "\ue77d", // 
".diff": "\uf440", //  ".diff": "\uf440", // 
".djvu": "\uf02d", //  ".djvu": "\uf02d", // 
".dll": "\ue70f", //  ".dll": "\ue70f", // 
".doc": "\uf1c2", //  ".doc": "\uf1c2", // 
".docx": "\uf1c2", //  ".docx": "\uf1c2", // 
".ds_store": "\uf179", //  ".ds_store": "\uf179", // 
".DS_store": "\uf179", //  ".DS_store": "\uf179", // 
".dump": "\uf1c0", //  ".dump": "\uf1c0", // 
".ebook": "\ue28b", //  ".ebook": "\ue28b", // 
".ebuild": "\uf30d", //  ".ebuild": "\uf30d", // 
".editorconfig": "\ue615", //  ".editorconfig": "\ue615", // 
".ejs": "\ue618", //  ".ejs": "\ue618", // 
".elm": "\ue62c", //  ".elm": "\ue62c", // 
".env": "\uf462", //  ".env": "\uf462", // 
".eot": "\uf031", //  ".eot": "\uf031", // 
".epub": "\ue28a", //  ".epub": "\ue28a", // 
".erb": "\ue73b", //  ".erb": "\ue73b", // 
".erl": "\ue7b1", //  ".erl": "\ue7b1", // 
".ex": "\ue62d", //  ".ex": "\ue62d", // 
".exe": "\uf17a", //  ".exe": "\uf17a", // 
".exs": "\ue62d", //  ".exs": "\ue62d", // 
".fish": "\uf489", //  ".fish": "\uf489", // 
".flac": "\uf001", //  ".flac": "\uf001", // 
".flv": "\uf03d", //  ".flv": "\uf03d", // 
".font": "\uf031", //  ".font": "\uf031", // 
".fs": "\ue7a7", //  ".fs": "\ue7a7", // 
".fsi": "\ue7a7", //  ".fsi": "\ue7a7", // 
".fsx": "\ue7a7", //  ".fsx": "\ue7a7", // 
".gdoc": "\uf1c2", //  ".gdoc": "\uf1c2", // 
".gem": "\ue21e", //  ".gem": "\ue21e", // 
".gemfile": "\ue21e", //  ".gemfile": "\ue21e", // 
".gemspec": "\ue21e", //  ".gemspec": "\ue21e", // 
".gform": "\uf298", //  ".gform": "\uf298", // 
".gif": "\uf1c5", //  ".gif": "\uf1c5", // 
".git": "\uf1d3", //  ".git": "\uf1d3", // 
".gitattributes": "\uf1d3", //  ".gitattributes": "\uf1d3", // 
".gitignore": "\uf1d3", //  ".gitignore": "\uf1d3", // 
".gitmodules": "\uf1d3", //  ".gitmodules": "\uf1d3", // 
".go": "\ue626", //  ".go": "\ue626", // 
".gradle": "\ue256", //  ".gradle": "\ue256", // 
".groovy": "\ue775", //  ".groovy": "\ue775", // 
".gsheet": "\uf1c3", //  ".gsheet": "\uf1c3", // 
".gslides": "\uf1c4", //  ".gslides": "\uf1c4", // 
".guardfile": "\ue21e", //  ".guardfile": "\ue21e", // 
".gz": "\uf410", //  ".gz": "\uf410", // 
".h": "\uf0fd", //  ".h": "\uf0fd", // 
".hbs": "\ue60f", //  ".hbs": "\ue60f", // 
".hpp": "\uf0fd", //  ".hpp": "\uf0fd", // 
".hs": "\ue777", //  ".hs": "\ue777", // 
".htm": "\uf13b", //  ".htm": "\uf13b", // 
".html": "\uf13b", //  ".html": "\uf13b", // 
".hxx": "\uf0fd", //  ".hxx": "\uf0fd", // 
".ico": "\uf1c5", //  ".ico": "\uf1c5", // 
".image": "\uf1c5", //  ".image": "\uf1c5", // 
".iml": "\ue7b5", //  ".iml": "\ue7b5", // 
".ini": "\uf17a", //  ".ini": "\uf17a", // 
".ipynb": "\ue606", //  ".ipynb": "\ue606", // 
".iso": "\ue271", //  ".iso": "\ue271", // 
".j2c": "\uf1c5", //  ".j2c": "\uf1c5", // 
".j2k": "\uf1c5", //  ".j2k": "\uf1c5", // 
".jad": "\ue256", //  ".jad": "\ue256", // 
".jar": "\ue256", //  ".jar": "\ue256", // 
".java": "\ue256", //  ".java": "\ue256", // 
".jfi": "\uf1c5", //  ".jfi": "\uf1c5", // 
".jfif": "\uf1c5", //  ".jfif": "\uf1c5", // 
".jif": "\uf1c5", //  ".jif": "\uf1c5", // 
".jl": "\ue624", //  ".jl": "\ue624", // 
".jmd": "\uf48a", //  ".jmd": "\uf48a", // 
".jp2": "\uf1c5", //  ".jp2": "\uf1c5", // 
".jpe": "\uf1c5", //  ".jpe": "\uf1c5", // 
".jpeg": "\uf1c5", //  ".jpeg": "\uf1c5", // 
".jpg": "\uf1c5", //  ".jpg": "\uf1c5", // 
".jpx": "\uf1c5", //  ".jpx": "\uf1c5", // 
".js": "\ue74e", //  ".js": "\ue74e", // 
".json": "\ue60b", //  ".json": "\ue60b", // 
".jsx": "\ue7ba", //  ".jsx": "\ue7ba", // 
".jxl": "\uf1c5", //  ".jxl": "\uf1c5", // 
".ksh": "\uf489", //  ".ksh": "\uf489", // 
".kt": "\ue634", //  ".kt": "\ue634", // 
".kts": "\ue634", //  ".kts": "\ue634", // 
".latex": "\uf034", //  ".latex": "\uf034", // 
".less": "\ue758", //  ".less": "\ue758", // 
".lhs": "\ue777", //  ".lhs": "\ue777", // 
".license": "\uf718", // ".license": "\U000f0219", // 󰈙
".localized": "\uf179", //  ".localized": "\uf179", // 
".lock": "\uf023", //  ".lock": "\uf023", // 
".log": "\uf18d", //  ".log": "\uf18d", // 
".lua": "\ue620", //  ".lua": "\ue620", // 
".lz": "\uf410", //  ".lz": "\uf410", // 
".lz4": "\uf410", //  ".lz4": "\uf410", // 
".lzh": "\uf410", //  ".lzh": "\uf410", // 
".lzma": "\uf410", //  ".lzma": "\uf410", // 
".lzo": "\uf410", //  ".lzo": "\uf410", // 
".m": "\ue61e", //  ".m": "\ue61e", // 
".mm": "\ue61d", //  ".mm": "\ue61d", // 
".m4a": "\uf001", //  ".m4a": "\uf001", // 
".markdown": "\uf48a", //  ".markdown": "\uf48a", // 
".md": "\uf48a", //  ".md": "\uf48a", // 
".mjs": "\ue74e", //  ".mjs": "\ue74e", // 
".mk": "\uf489", //  ".mk": "\uf489", // 
".mkd": "\uf48a", //  ".mkd": "\uf48a", // 
".mkv": "\uf03d", //  ".mkv": "\uf03d", // 
".mobi": "\ue28b", //  ".mobi": "\ue28b", // 
".mov": "\uf03d", //  ".mov": "\uf03d", // 
".mp3": "\uf001", //  ".mp3": "\uf001", // 
".mp4": "\uf03d", //  ".mp4": "\uf03d", // 
".msi": "\ue70f", //  ".msi": "\ue70f", // 
".mustache": "\ue60f", //  ".mustache": "\ue60f", // 
".nix": "\uf313", //  ".nix": "\uf313", // 
".node": "\uf898", // ".node": "\U000f0399", // 󰎙
".npmignore": "\ue71e", //  ".npmignore": "\ue71e", // 
".odp": "\uf1c4", //  ".odp": "\uf1c4", // 
".ods": "\uf1c3", //  ".ods": "\uf1c3", // 
".odt": "\uf1c2", //  ".odt": "\uf1c2", // 
".ogg": "\uf001", //  ".ogg": "\uf001", // 
".ogv": "\uf03d", //  ".ogv": "\uf03d", // 
".otf": "\uf031", //  ".otf": "\uf031", // 
".part": "\uf43a", //  ".part": "\uf43a", // 
".patch": "\uf440", //  ".patch": "\uf440", // 
".pdf": "\uf1c1", //  ".pdf": "\uf1c1", // 
".php": "\ue73d", //  ".php": "\ue73d", // 
".pl": "\ue769", //  ".pl": "\ue769", // 
".png": "\uf1c5", //  ".png": "\uf1c5", // 
".ppt": "\uf1c4", //  ".ppt": "\uf1c4", // 
".pptx": "\uf1c4", //  ".pptx": "\uf1c4", // 
".procfile": "\ue21e", //  ".procfile": "\ue21e", // 
".properties": "\ue60b", //  ".properties": "\ue60b", // 
".ps1": "\uf489", //  ".ps1": "\uf489", // 
".psd": "\ue7b8", //  ".psd": "\ue7b8", // 
".pxm": "\uf1c5", //  ".pxm": "\uf1c5", // 
".py": "\ue606", //  ".py": "\ue606", // 
".pyc": "\ue606", //  ".pyc": "\ue606", // 
".r": "\uf25d", //  ".r": "\uf25d", // 
".rakefile": "\ue21e", //  ".rakefile": "\ue21e", // 
".rar": "\uf410", //  ".rar": "\uf410", // 
".razor": "\uf1fa", //  ".razor": "\uf1fa", // 
".rb": "\ue21e", //  ".rb": "\ue21e", // 
".rdata": "\uf25d", //  ".rdata": "\uf25d", // 
".rdb": "\ue76d", //  ".rdb": "\ue76d", // 
".rdoc": "\uf48a", //  ".rdoc": "\uf48a", // 
".rds": "\uf25d", //  ".rds": "\uf25d", // 
".readme": "\uf48a", //  ".readme": "\uf48a", // 
".rlib": "\ue7a8", //  ".rlib": "\ue7a8", // 
".rmd": "\uf48a", //  ".rmd": "\uf48a", // 
".rpm": "\ue7bb", //  ".rpm": "\ue7bb", // 
".rs": "\ue7a8", //  ".rs": "\ue7a8", // 
".rspec": "\ue21e", //  ".rspec": "\ue21e", // 
".rspec_parallel": "\ue21e", //  ".rspec_parallel": "\ue21e", // 
".rspec_status": "\ue21e", //  ".rspec_status": "\ue21e", // 
".rss": "\uf09e", //  ".rss": "\uf09e", // 
".rtf": "\uf718", // ".rtf": "\U000f0219", // 󰈙
".ru": "\ue21e", //  ".ru": "\ue21e", // 
".rubydoc": "\ue73b", //  ".rubydoc": "\ue73b", // 
".sass": "\ue603", //  ".sass": "\ue603", // 
".scala": "\ue737", //  ".scala": "\ue737", // 
".scss": "\ue749", //  ".scss": "\ue749", // 
".sh": "\uf489", //  ".sh": "\uf489", // 
".shell": "\uf489", //  ".shell": "\uf489", // 
".slim": "\ue73b", //  ".slim": "\ue73b", // 
".sln": "\ue70c", //  ".sln": "\ue70c", // 
".so": "\uf17c", //  ".so": "\uf17c", // 
".sql": "\uf1c0", //  ".sql": "\uf1c0", // 
".sqlite3": "\ue7c4", //  ".sqlite3": "\ue7c4", // 
".sty": "\uf034", //  ".sty": "\uf034", // 
".styl": "\ue600", //  ".styl": "\ue600", // 
".stylus": "\ue600", //  ".stylus": "\ue600", // 
".svg": "\uf1c5", //  ".svg": "\uf1c5", // 
".swift": "\ue755", //  ".swift": "\ue755", // 
".tar": "\uf410", //  ".tar": "\uf410", // 
".taz": "\uf410", //  ".taz": "\uf410", // 
".tbz": "\uf410", //  ".tbz": "\uf410", // 
".tbz2": "\uf410", //  ".tbz2": "\uf410", // 
".tex": "\uf034", //  ".tex": "\uf034", // 
".tgz": "\uf410", //  ".tgz": "\uf410", // 
".tiff": "\uf1c5", //  ".tiff": "\uf1c5", // 
".tlz": "\uf410", //  ".tlz": "\uf410", // 
".toml": "\ue615", //  ".toml": "\ue615", // 
".torrent": "\ue275", //  ".torrent": "\ue275", // 
".ts": "\ue628", //  ".ts": "\ue628", // 
".tsv": "\uf1c3", //  ".tsv": "\uf1c3", // 
".tsx": "\ue7ba", //  ".tsx": "\ue7ba", // 
".ttf": "\uf031", //  ".ttf": "\uf031", // 
".twig": "\ue61c", //  ".twig": "\ue61c", // 
".txt": "\uf15c", //  ".txt": "\uf15c", // 
".txz": "\uf410", //  ".txz": "\uf410", // 
".tz": "\uf410", //  ".tz": "\uf410", // 
".tzo": "\uf410", //  ".tzo": "\uf410", // 
".video": "\uf03d", //  ".video": "\uf03d", // 
".vim": "\ue62b", //  ".vim": "\ue62b", // 
".vue": "\ufd42", // ".vue": "\U000f0844", // 󰡄
".war": "\ue256", //  ".war": "\ue256", // 
".wav": "\uf001", //  ".wav": "\uf001", // 
".webm": "\uf03d", //  ".webm": "\uf03d", // 
".webp": "\uf1c5", //  ".webp": "\uf1c5", // 
".windows": "\uf17a", //  ".windows": "\uf17a", // 
".woff": "\uf031", //  ".woff": "\uf031", // 
".woff2": "\uf031", //  ".woff2": "\uf031", // 
".xhtml": "\uf13b", //  ".xhtml": "\uf13b", // 
".xls": "\uf1c3", //  ".xls": "\uf1c3", // 
".xlsx": "\uf1c3", //  ".xlsx": "\uf1c3", // 
".xml": "\uf121", //  ".xml": "\uf121", // 
".xul": "\uf121", //  ".xul": "\uf121", // 
".xz": "\uf410", //  ".xz": "\uf410", // 
".yaml": "\uf481", //  ".yaml": "\uf481", // 
".yml": "\uf481", //  ".yml": "\uf481", // 
".zip": "\uf410", //  ".zip": "\uf410", // 
".zsh": "\uf489", //  ".zsh": "\uf489", // 
".zsh-theme": "\uf489", //  ".zsh-theme": "\uf489", // 
".zshrc": "\uf489", //  ".zshrc": "\uf489", // 
".zst": "\uf410", //  ".zst": "\uf410", // 
}
func patchFileIconsForNerdFontsV2() {
extIconMap[".cs"] = "\uf81a" // 
extIconMap[".csproj"] = "\uf81a" // 
extIconMap[".csx"] = "\uf81a" // 
extIconMap[".license"] = "\uf718" // 
extIconMap[".node"] = "\uf898" // 
extIconMap[".rtf"] = "\uf718" // 
extIconMap[".vue"] = "\ufd42" // ﵂
} }
func IconForFile(name string, isSubmodule bool, isDirectory bool) string { func IconForFile(name string, isSubmodule bool, isDirectory bool) string {

View File

@ -6,26 +6,30 @@ import (
"github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/commands/models"
) )
const ( var (
BRANCH_ICON = "\ufb2b" // BRANCH_ICON = "\U000f062c" // 󰘬
DETACHED_HEAD_ICON = "\ue729" //  DETACHED_HEAD_ICON = "\ue729" // 
TAG_ICON = "\uf02b" //  TAG_ICON = "\uf02b" // 
COMMIT_ICON = "\ufc16" // COMMIT_ICON = "\U000f0718" // 󰜘
MERGE_COMMIT_ICON = "\ufb2c" // MERGE_COMMIT_ICON = "\U000f062d" // 󰘭
DEFAULT_REMOTE_ICON = "\uf7a1" // DEFAULT_REMOTE_ICON = "\uf02a2" // 󰊢
STASH_ICON = "\uf01c" //  STASH_ICON = "\uf01c" // 
) )
type remoteIcon struct { var remoteIcons = map[string]string{
domain string "github.com": "\ue709", // 
icon string "bitbucket.org": "\ue703", // 
"gitlab.com": "\uf296", // 
"dev.azure.com": "\U000f0805", // 󰠅
} }
var remoteIcons = []remoteIcon{ func patchGitIconsForNerdFontsV2() {
{domain: "github.com", icon: "\ue709"}, // BRANCH_ICON = "\ufb2b" //
{domain: "bitbucket.org", icon: "\ue703"}, // COMMIT_ICON = "\ufc16" //
{domain: "gitlab.com", icon: "\uf296"}, // MERGE_COMMIT_ICON = "\ufb2c" //
{domain: "dev.azure.com", icon: "\ufd03"}, // DEFAULT_REMOTE_ICON = "\uf7a1" //
remoteIcons["dev.azure.com"] = "\ufd03" // ﴃ
} }
func IconForBranch(branch *models.Branch) string { func IconForBranch(branch *models.Branch) string {
@ -51,10 +55,10 @@ func IconForCommit(commit *models.Commit) string {
} }
func IconForRemote(remote *models.Remote) string { func IconForRemote(remote *models.Remote) string {
for _, r := range remoteIcons { for domain, icon := range remoteIcons {
for _, url := range remote.Urls { for _, url := range remote.Urls {
if strings.Contains(url, r.domain) { if strings.Contains(url, domain) {
return r.icon return icon
} }
} }
} }

View File

@ -1,11 +1,26 @@
package icons package icons
import (
"log"
"github.com/samber/lo"
)
var isIconEnabled = false var isIconEnabled = false
func IsIconEnabled() bool { func IsIconEnabled() bool {
return isIconEnabled return isIconEnabled
} }
func SetIconEnabled(showIcons bool) { func SetNerdFontsVersion(version string) {
isIconEnabled = showIcons if !lo.Contains([]string{"2", "3"}, version) {
log.Fatalf("Unsupported nerdFontVersion %s", version)
}
if version == "2" {
patchGitIconsForNerdFontsV2()
patchFileIconsForNerdFontsV2()
}
isIconEnabled = true
} }