diff --git a/main.go b/main.go index bf28ebae..aaf158a5 100644 --- a/main.go +++ b/main.go @@ -54,6 +54,7 @@ type args struct { ShortenGKENames *bool ShortenEKSNames *bool ShellVar *string + TrimADDomain *bool PathAliases *string Duration *string DurationMin *string @@ -243,6 +244,10 @@ func main() { "shell-var", "", comments("A shell variable to add to the segments.")), + TrimADDomain: flag.Bool( + "trim-ad-domain", + false, + comments("Trim the Domainname from the AD username.")), PathAliases: flag.String( "path-aliases", "", diff --git a/powerline.go b/powerline.go index 341c9a4d..3a2b367b 100644 --- a/powerline.go +++ b/powerline.go @@ -69,6 +69,13 @@ func newPowerline(args args, cwd string, priorities map[string]int, align alignm } else { p.username = p.userInfo.Username } + if args.TrimADDomain != nil && *args.TrimADDomain { + usernameWithAd := strings.SplitN(p.username, `\`, 2) + if len(usernameWithAd) > 1 { + // remove the Domain name from username + p.username = usernameWithAd[1] + } + } p.theme = themes[*args.Theme] p.shellInfo = shellInfos[*args.Shell]