-
-
Notifications
You must be signed in to change notification settings - Fork 280
Expand file tree
/
Copy pathsegment-aws.go
More file actions
40 lines (31 loc) · 664 Bytes
/
segment-aws.go
File metadata and controls
40 lines (31 loc) · 664 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"os"
pwl "github.com/justjanne/powerline-go/powerline"
)
func segmentAWS(p *powerline) []pwl.Segment {
profile := os.Getenv("AWS_PROFILE")
region := os.Getenv("AWS_DEFAULT_REGION")
var content string = ""
if len(profile) == 0 {
profile = os.Getenv("AWS_VAULT")
}
if len(region) == 0 {
region = os.Getenv("AWS_REGION")
}
if len(region) > 0 {
content = "(" + region + ")"
}
if len(profile) > 0 {
content = profile +" "+ content
}
if len(content) == 0 {
return []pwl.Segment{}
}
return []pwl.Segment{{
Name: "aws",
Content: content,
Foreground: p.theme.AWSFg,
Background: p.theme.AWSBg,
}}
}