Skip to content

Commit

Permalink
Merge pull request #236 from mschneider82/trimADDomain
Browse files Browse the repository at this point in the history
Added -trim-ad-domain to trim windows domains from username #235
  • Loading branch information
justjanne authored Oct 2, 2020
2 parents 51cdcc0 + 8a93d6a commit 677c046
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type args struct {
ShortenGKENames *bool
ShortenEKSNames *bool
ShellVar *string
TrimADDomain *bool
PathAliases *string
Duration *string
DurationMin *string
Expand Down Expand Up @@ -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",
"",
Expand Down
7 changes: 7 additions & 0 deletions powerline.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 677c046

Please sign in to comment.