mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-13 14:34:06 -08:00
refactor: swap go-ps for gopsutil
This commit is contained in:
parent
9379c99931
commit
9c1bf12c82
|
@ -12,8 +12,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/distatus/battery"
|
"github.com/distatus/battery"
|
||||||
ps "github.com/mitchellh/go-ps"
|
|
||||||
"github.com/shirou/gopsutil/host"
|
"github.com/shirou/gopsutil/host"
|
||||||
|
"github.com/shirou/gopsutil/process"
|
||||||
)
|
)
|
||||||
|
|
||||||
type environmentInfo interface {
|
type environmentInfo interface {
|
||||||
|
@ -173,12 +173,12 @@ func (env *environment) getBatteryInfo() (*battery.Battery, error) {
|
||||||
|
|
||||||
func (env *environment) getShellName() string {
|
func (env *environment) getShellName() string {
|
||||||
pid := os.Getppid()
|
pid := os.Getppid()
|
||||||
p, err := ps.FindProcess(pid)
|
p, _ := process.NewProcess(int32(pid))
|
||||||
|
name, err := p.Name()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "unknown"
|
return "unknown"
|
||||||
}
|
}
|
||||||
shell := strings.Replace(p.Executable(), ".exe", "", 1)
|
shell := strings.Replace(name, ".exe", "", 1)
|
||||||
return strings.Trim(shell, " ")
|
return strings.Trim(shell, " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
go.mod
1
go.mod
|
@ -7,7 +7,6 @@ require (
|
||||||
github.com/distatus/battery v0.10.1-0.20200722221337-7e1bf2bbb15c
|
github.com/distatus/battery v0.10.1-0.20200722221337-7e1bf2bbb15c
|
||||||
github.com/go-ole/go-ole v1.2.4 // indirect
|
github.com/go-ole/go-ole v1.2.4 // indirect
|
||||||
github.com/gookit/color v1.3.1
|
github.com/gookit/color v1.3.1
|
||||||
github.com/mitchellh/go-ps v1.0.0
|
|
||||||
github.com/shirou/gopsutil v2.20.9+incompatible
|
github.com/shirou/gopsutil v2.20.9+incompatible
|
||||||
github.com/stretchr/objx v0.3.0 // indirect
|
github.com/stretchr/objx v0.3.0 // indirect
|
||||||
github.com/stretchr/testify v1.6.1
|
github.com/stretchr/testify v1.6.1
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -2,8 +2,6 @@ github.com/JanDeDobbeleer/battery v0.10.1-0.20200909080331-bb0a7566dbb8 h1:+SZ7q
|
||||||
github.com/JanDeDobbeleer/battery v0.10.1-0.20200909080331-bb0a7566dbb8/go.mod h1:STnSvFLX//eEpkaN7qWRxCWxrWOcssTDgnG4yqq9BRE=
|
github.com/JanDeDobbeleer/battery v0.10.1-0.20200909080331-bb0a7566dbb8/go.mod h1:STnSvFLX//eEpkaN7qWRxCWxrWOcssTDgnG4yqq9BRE=
|
||||||
github.com/JanDeDobbeleer/color v1.3.1-0.20201014085303-5ffcdf66388a h1:0gU8YI1Z9jXOeMbUxRQR6/XznZTKXSQcVuoFZtbrkN8=
|
github.com/JanDeDobbeleer/color v1.3.1-0.20201014085303-5ffcdf66388a h1:0gU8YI1Z9jXOeMbUxRQR6/XznZTKXSQcVuoFZtbrkN8=
|
||||||
github.com/JanDeDobbeleer/color v1.3.1-0.20201014085303-5ffcdf66388a/go.mod h1:R3ogXq2B9rTbXoSHJ1HyUVAZ3poOJHpd9nQmyGZsfvQ=
|
github.com/JanDeDobbeleer/color v1.3.1-0.20201014085303-5ffcdf66388a/go.mod h1:R3ogXq2B9rTbXoSHJ1HyUVAZ3poOJHpd9nQmyGZsfvQ=
|
||||||
github.com/JanDeDobbeleer/go-ps v1.0.0 h1:3nqwUNAIzjrjQoEdZDVcS5OCm+KIoShKnANJ5xfkgBY=
|
|
||||||
github.com/JanDeDobbeleer/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg=
|
|
||||||
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk=
|
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk=
|
||||||
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
|
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
|
Loading…
Reference in a new issue