mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-09-19 21:17:31 -07:00
parent
56f4bcfd86
commit
56468baf4c
|
@ -5,7 +5,6 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
@ -64,16 +63,6 @@ func (env *environment) getcwd() string {
|
|||
return env.cwd
|
||||
}
|
||||
|
||||
func (env *environment) homeDir() string {
|
||||
usr, err := user.Current()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
homeDir := usr.HomeDir
|
||||
// on Windows, and being case sentisitive and not consistent and all, this gives silly issues
|
||||
return strings.Replace(homeDir, "c:", "C:", 1)
|
||||
}
|
||||
|
||||
func (env *environment) hasFiles(pattern string) bool {
|
||||
cwd := env.getcwd()
|
||||
pattern = cwd + env.getPathSeperator() + pattern
|
||||
|
|
|
@ -9,3 +9,7 @@ import (
|
|||
func (env *environment) isRunningAsRoot() bool {
|
||||
return os.Geteuid() == 0
|
||||
}
|
||||
|
||||
func (env *environment) homeDir() string {
|
||||
return os.Getenv("HOME")
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
|
@ -35,3 +37,11 @@ func (env *environment) isRunningAsRoot() bool {
|
|||
|
||||
return member
|
||||
}
|
||||
|
||||
func (env *environment) homeDir() string {
|
||||
home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH")
|
||||
if home == "" {
|
||||
home = os.Getenv("USERPROFILE")
|
||||
}
|
||||
return home
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue