refactor: cache shell name

This commit is contained in:
Jan De Dobbeleer 2020-12-27 14:59:40 +01:00 committed by Jan De Dobbeleer
parent 85ee0bb0c0
commit b427a0e8a4
2 changed files with 4 additions and 5 deletions

View file

@ -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()

View file

@ -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,