From a3cc8160d3741c2ee2b9fe9dfa6c1df26cc1f451 Mon Sep 17 00:00:00 2001 From: sammyette <38820196+TorchedSammy@users.noreply.github.com> Date: Thu, 8 Jul 2021 03:44:57 -0700 Subject: [PATCH] fix: trim off hostname in %u verb for windows --- hilbish.go | 4 +++- main.go | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/hilbish.go b/hilbish.go index 003d0b4..8708cfe 100644 --- a/hilbish.go +++ b/hilbish.go @@ -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)) diff --git a/main.go b/main.go index 828e904..ab0c515 100644 --- a/main.go +++ b/main.go @@ -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 {