diff --git a/hilbish.go b/hilbish.go index 8708cfe..773affb 100644 --- a/hilbish.go +++ b/hilbish.go @@ -5,6 +5,7 @@ package main import ( "os" + "runtime" "strings" "github.com/pborman/getopt" @@ -22,7 +23,11 @@ func HilbishLoader(L *lua.LState) int { mod := L.SetFuncs(L.NewTable(), exports) host, _ := os.Hostname() - username := strings.Split(curuser.Username, "\\")[1] // for some reason Username includes the hostname on windows + username := curuser.Username + // this will be baked into binary since GOOS is a constant + if runtime.GOOS == "windows" { + username = strings.Split(username, "\\")[1] // for some reason Username includes the hostname on windows + } L.SetField(mod, "ver", lua.LString(version)) L.SetField(mod, "user", lua.LString(username)) diff --git a/main.go b/main.go index ab0c515..30195aa 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "os" + "runtime" "strings" "os/signal" "os/user" @@ -265,7 +266,11 @@ func fmtPrompt() string { cwd, _ := os.Getwd() cwd = strings.Replace(cwd, curuser.HomeDir, "~", 1) - username := strings.Split(curuser.Username, "\\")[1] // for some reason Username includes the hostname on windows + username := curuser.Username + // this will be baked into binary since GOOS is a constant + if runtime.GOOS == "windows" { + username = strings.Split(username, "\\")[1] // for some reason Username includes the hostname on windows + } args := []string{ "d", cwd,