forked from JanDeDobbeleer/oh-my-posh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsegment_os.go
136 lines (129 loc) · 3.73 KB
/
segment_os.go
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package main
import (
"fmt"
)
type osInfo struct {
props *properties
env environmentInfo
}
const (
//MacOS the string/icon to use for MacOS
MacOS Property = "macos"
//Linux the string/icon to use for linux
Linux Property = "linux"
//Windows the string/icon to use for windows
Windows Property = "windows"
//WSL the string/icon to use for WSL
WSL Property = "wsl"
//WSLSeparator shows between WSL and Linux properties when WSL is detected
WSLSeparator Property = "wsl_separator"
//Alpine the string/icon to use for Alpine
Alpine Property = "alpine"
//Aosc the string/icon to use for Aosc
Aosc Property = "aosc"
//Arch the string/icon to use for Arch
Arch Property = "arch"
//Centos the string/icon to use for Centos
Centos Property = "centos"
//Coreos the string/icon to use for Coreos
Coreos Property = "coreos"
//Debian the string/icon to use for Debian
Debian Property = "debian"
//Devuan the string/icon to use for Devuan
Devuan Property = "devuan"
//Raspbian the string/icon to use for Raspbian
Raspbian Property = "raspbian"
//Elementary the string/icon to use for Elementary
Elementary Property = "elementary"
//Fedora the string/icon to use for Fedora
Fedora Property = "fedora"
//Gentoo the string/icon to use for Gentoo
Gentoo Property = "gentoo"
//Mageia the string/icon to use for Mageia
Mageia Property = "mageia"
//Manjaro the string/icon to use for Manjaro
Manjaro Property = "manjaro"
//Mint the string/icon to use for Mint
Mint Property = "mint"
//Nixos the string/icon to use for Nixos
Nixos Property = "nixos"
//Opensuse the string/icon to use for Opensuse
Opensuse Property = "opensuse"
//Sabayon the string/icon to use for Sabayon
Sabayon Property = "sabayon"
//Slackware the string/icon to use for Slackware
Slackware Property = "slackware"
//Ubuntu the string/icon to use for Ubuntu
Ubuntu Property = "ubuntu"
)
func (n *osInfo) enabled() bool {
return true
}
func (n *osInfo) string() string {
goos := n.env.getRuntimeGOOS()
switch goos {
case "windows":
return n.props.getString(Windows, "\uE62A")
case "darwin":
return n.props.getString(MacOS, "\uF179")
case "linux":
wsl := n.env.getenv("WSL_DISTRO_NAME")
p := n.env.getPlatform()
if wsl != "" {
return fmt.Sprintf("%s%s%s",
n.props.getString(WSL, "WSL"),
n.props.getString(WSLSeparator, " - "),
getLinuxIcon(n, p))
}
return getLinuxIcon(n, p)
default:
return ""
}
}
func getLinuxIcon(n *osInfo, p string) string {
switch p {
case "alpine":
return n.props.getString(Alpine, "\uF300")
case "aosc":
return n.props.getString(Aosc, "\uF301")
case "arch":
return n.props.getString(Arch, "\uF303")
case "centos":
return n.props.getString(Centos, "\uF304")
case "coreos":
return n.props.getString(Coreos, "\uF305")
case "debian":
return n.props.getString(Debian, "\uF306")
case "devuan":
return n.props.getString(Devuan, "\uF307")
case "raspbian":
return n.props.getString(Raspbian, "\uF315")
case "elementary":
return n.props.getString(Elementary, "\uF309")
case "fedora":
return n.props.getString(Fedora, "\uF30a")
case "gentoo":
return n.props.getString(Gentoo, "\uF30d")
case "mageia":
return n.props.getString(Mageia, "\uF310")
case "manjaro":
return n.props.getString(Manjaro, "\uF312")
case "mint":
return n.props.getString(Mint, "\uF30e")
case "nixos":
return n.props.getString(Nixos, "\uF313")
case "opensuse":
return n.props.getString(Opensuse, "\uF314")
case "sabayon":
return n.props.getString(Sabayon, "\uF317")
case "slackware":
return n.props.getString(Slackware, "\uF319")
case "ubuntu":
return n.props.getString(Ubuntu, "\uF31b")
}
return n.props.getString(Linux, "\uF17C")
}
func (n *osInfo) init(props *properties, env environmentInfo) {
n.props = props
n.env = env
}