2
2
kopie van https://github.com/Hilbis/Hilbish synced 2025-07-18 16:52:02 +00:00

fix: trim off hostname in %u verb for windows

This commit is contained in:
sammyette 2021-07-08 03:44:57 -07:00
bovenliggende 4caeb7ec91
commit a3cc8160d3
2 gewijzigde bestanden met toevoegingen van 5 en 2 verwijderingen

Bestand weergeven

@ -5,6 +5,7 @@ package main
import ( import (
"os" "os"
"strings"
"github.com/pborman/getopt" "github.com/pborman/getopt"
"github.com/yuin/gopher-lua" "github.com/yuin/gopher-lua"
@ -21,9 +22,10 @@ func HilbishLoader(L *lua.LState) int {
mod := L.SetFuncs(L.NewTable(), exports) mod := L.SetFuncs(L.NewTable(), exports)
host, _ := os.Hostname() 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, "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, "host", lua.LString(host))
L.SetField(mod, "home", lua.LString(homedir)) L.SetField(mod, "home", lua.LString(homedir))

Bestand weergeven

@ -265,12 +265,13 @@ func fmtPrompt() string {
cwd, _ := os.Getwd() cwd, _ := os.Getwd()
cwd = strings.Replace(cwd, curuser.HomeDir, "~", 1) cwd = strings.Replace(cwd, curuser.HomeDir, "~", 1)
username := strings.Split(curuser.Username, "\\")[1] // for some reason Username includes the hostname on windows
args := []string{ args := []string{
"d", cwd, "d", cwd,
"D", filepath.Base(cwd), "D", filepath.Base(cwd),
"h", host, "h", host,
"u", curuser.Username, "u", username,
} }
for i, v := range args { for i, v := range args {