diff --git a/pkg/gui/presentation/icons/git_icons.go b/pkg/gui/presentation/icons/git_icons.go index 8acfead2b..0f891d7bd 100644 --- a/pkg/gui/presentation/icons/git_icons.go +++ b/pkg/gui/presentation/icons/git_icons.go @@ -1,14 +1,31 @@ package icons import ( + "strings" + "github.com/jesseduffield/lazygit/pkg/commands/models" ) -const BRANCH_ICON = "\ufb2b" // שׂ -const DETACHED_HEAD_ICON = "\ue729" //  -const TAG_ICON = "\uf02b" //  -const COMMIT_ICON = "\ufc16" // ﰖ -const MERGE_COMMIT_ICON = "\ufb2c" // שּׁ +const ( + BRANCH_ICON = "\ufb2b" // שׂ + DETACHED_HEAD_ICON = "\ue729" //  + TAG_ICON = "\uf02b" //  + COMMIT_ICON = "\ufc16" // ﰖ + MERGE_COMMIT_ICON = "\ufb2c" // שּׁ + DEFAULT_REMOTE_ICON = "\uf7a1" //  +) + +type remoteIcon struct { + domain string + icon string +} + +var remoteIcons = []remoteIcon{ + {domain: "github.com", icon: "\ue709"}, //  + {domain: "bitbucket.org", icon: "\ue703"}, //  + {domain: "gitlab.com", icon: "\uf296"}, //  + {domain: "dev.azure.com", icon: "\ufd03"}, // ﴃ +} func IconForBranch(branch *models.Branch) string { if branch.DisplayName != "" { @@ -31,3 +48,14 @@ func IconForCommit(commit *models.Commit) string { } return COMMIT_ICON } + +func IconForRemote(remote *models.Remote) string { + for _, r := range remoteIcons { + for _, url := range remote.Urls { + if strings.Contains(url, r.domain) { + return r.icon + } + } + } + return DEFAULT_REMOTE_ICON +} diff --git a/pkg/gui/presentation/remotes.go b/pkg/gui/presentation/remotes.go index 9b26cbfae..7f82fe970 100644 --- a/pkg/gui/presentation/remotes.go +++ b/pkg/gui/presentation/remotes.go @@ -3,6 +3,7 @@ package presentation import ( "github.com/jesseduffield/generics/slices" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gui/presentation/icons" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/theme" ) @@ -23,5 +24,10 @@ func getRemoteDisplayStrings(r *models.Remote, diffed bool) []string { textStyle = theme.DiffTerminalColor } - return []string{textStyle.Sprint(r.Name), style.FgBlue.Sprintf("%d branches", branchCount)} + res := make([]string, 0, 3) + if icons.IsIconEnabled() { + res = append(res, textStyle.Sprint(icons.IconForRemote(r))) + } + res = append(res, textStyle.Sprint(r.Name), style.FgBlue.Sprintf("%d branches", branchCount)) + return res }