oh-my-posh/src/environment_unix.go

40 lines
922 B
Go
Raw Normal View History

2019-03-13 04:14:30 -07:00
// +build !windows
package main
import (
2020-11-04 23:56:12 -08:00
"errors"
2019-03-13 04:14:30 -07:00
"os"
"time"
terminal "github.com/wayneashleyberry/terminal-dimensions"
2019-03-13 04:14:30 -07:00
)
func (env *environment) isRunningAsRoot() bool {
defer env.tracer.trace(time.Now(), "isRunningAsRoot")
2019-03-13 04:14:30 -07:00
return os.Geteuid() == 0
}
func (env *environment) homeDir() string {
return os.Getenv("HOME")
}
2020-11-04 23:56:12 -08:00
func (env *environment) getWindowTitle(imageName, windowTitleRegex string) (string, error) {
2020-11-04 23:56:12 -08:00
return "", errors.New("not implemented")
}
func (env *environment) isWsl() bool {
defer env.tracer.trace(time.Now(), "isWsl")
// one way to check
// version := env.getFileContent("/proc/version")
// return strings.Contains(version, "microsoft")
// using env variable
return env.getenv("WSL_DISTRO_NAME") != ""
}
func (env *environment) getTerminalWidth() (int, error) {
defer env.tracer.trace(time.Now(), "getTerminalWidth")
width, err := terminal.Width()
return int(width), err
}