fix: trim off hostname in %u verb for windows

pull/69/head
sammyette 2021-07-08 03:44:57 -07:00
parent 4caeb7ec91
commit a3cc8160d3
2 changed files with 5 additions and 2 deletions

View File

@ -5,6 +5,7 @@ package main
import (
"os"
"strings"
"github.com/pborman/getopt"
"github.com/yuin/gopher-lua"
@ -21,9 +22,10 @@ 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
L.SetField(mod, "ver", lua.LString(version))
L.SetField(mod, "user", lua.LString(curuser.Username))
L.SetField(mod, "user", lua.LString(username))
L.SetField(mod, "host", lua.LString(host))
L.SetField(mod, "home", lua.LString(homedir))

View File

@ -265,12 +265,13 @@ 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
args := []string{
"d", cwd,
"D", filepath.Base(cwd),
"h", host,
"u", curuser.Username,
"u", username,
}
for i, v := range args {