Skip to content

Commit 8261d0a

Browse files
committed
update logic to profile OR region
1 parent 82fec22 commit 8261d0a

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

segment-aws.go

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,31 @@ import (
99
func segmentAWS(p *powerline) []pwl.Segment {
1010
profile := os.Getenv("AWS_PROFILE")
1111
region := os.Getenv("AWS_DEFAULT_REGION")
12-
if profile == "" {
12+
var content string = ""
13+
14+
if len(profile) == 0 {
1315
profile = os.Getenv("AWS_VAULT")
14-
if profile == "" {
15-
return []pwl.Segment{}
16-
}
1716
}
18-
var r string
19-
if region != "" {
20-
r = " (" + region + ")"
17+
18+
if len(region) == 0 {
19+
region = os.Getenv("AWS_REGION")
2120
}
21+
22+
if len(region) > 0 {
23+
content = "(" + region + ")"
24+
}
25+
26+
if len(profile) > 0 {
27+
content = profile +" "+ content
28+
}
29+
30+
if len(content) == 0 {
31+
return []pwl.Segment{}
32+
}
33+
2234
return []pwl.Segment{{
2335
Name: "aws",
24-
Content: profile + r,
36+
Content: content,
2537
Foreground: p.theme.AWSFg,
2638
Background: p.theme.AWSBg,
2739
}}

0 commit comments

Comments
 (0)