mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-30 04:21:19 -08:00
refactor: cache shell name
This commit is contained in:
parent
85ee0bb0c0
commit
b427a0e8a4
|
@ -217,6 +217,9 @@ func (env *environment) getBatteryInfo() (*battery.Battery, error) {
|
|||
}
|
||||
|
||||
func (env *environment) getShellName() string {
|
||||
if *env.args.Shell != "" {
|
||||
return *env.args.Shell
|
||||
}
|
||||
pid := os.Getppid()
|
||||
p, _ := process.NewProcess(int32(pid))
|
||||
name, err := p.Name()
|
||||
|
|
|
@ -127,12 +127,8 @@ func main() {
|
|||
fmt.Println(Version)
|
||||
return
|
||||
}
|
||||
shell := env.getShellName()
|
||||
if *args.Shell != "" {
|
||||
shell = *args.Shell
|
||||
}
|
||||
formats := &ansiFormats{}
|
||||
formats.init(shell)
|
||||
formats.init(env.getShellName())
|
||||
renderer := &AnsiRenderer{
|
||||
buffer: new(bytes.Buffer),
|
||||
formats: formats,
|
||||
|
|
Loading…
Reference in a new issue