Skip to content

Commit

Permalink
refactor: cache shell name
Browse files Browse the repository at this point in the history
  • Loading branch information
JanDeDobbeleer committed Dec 27, 2020
1 parent 85ee0bb commit b427a0e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/environment.go
Expand Up @@ -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()
Expand Down
6 changes: 1 addition & 5 deletions src/main.go
Expand Up @@ -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,
Expand Down

0 comments on commit b427a0e

Please sign in to comment.