mirror of https://github.com/Hilbis/Hilbish
fix: trim off hostname in %u verb for windows
parent
4caeb7ec91
commit
a3cc8160d3
|
@ -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))
|
||||||
|
|
||||||
|
|
3
main.go
3
main.go
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue