Compare commits

..

4 Commits

Author SHA1 Message Date
sammyette 196526cc6a fix: rename unix vars to linux 2021-07-08 17:55:19 -07:00
sammyette 5d78a0c574 feat: add compile vars for windows 2021-07-08 17:49:51 -07:00
sammyette a3cc8160d3 fix: trim off hostname in %u verb for windows 2021-07-08 03:44:57 -07:00
sammyette 4caeb7ec91 feat: replace ~ in preloadPath and sampleConfPath with homedir 2021-07-08 03:44:11 -07:00
5 changed files with 37 additions and 13 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

@ -40,6 +40,8 @@ var (
func main() {
homedir, _ = os.UserHomeDir()
curuser, _ = user.Current()
preloadPath = strings.Replace(preloadPath, "~", homedir, 1)
sampleConfPath = strings.Replace(sampleConfPath, "~", homedir, 1)
if defaultConfDir == "" {
// we'll add *our* default if its empty (wont be if its changed comptime)
@ -263,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 {

11
vars.go
View File

@ -3,18 +3,7 @@ package main
// String vars that are free to be changed at compile time
var (
version = "v0.5.1"
requirePaths = `';./libs/?/init.lua;./?/init.lua;./?/?.lua'
.. ';/usr/share/hilbish/libs/?/init.lua;'
.. ';/usr/share/hilbish/libs/?/?.lua;'
.. hilbish.home .. '/.local/share/hilbish/libs/?/init.lua;'
.. hilbish.home .. '/.local/share/hilbish/libs/?/?.lua;'
.. hilbish.home .. '/.local/share/hilbish/libs/?.lua'
.. hilbish.home .. '/.config/hilbish/?/init.lua'
.. hilbish.home .. '/.config/hilbish/?/?.lua'
.. hilbish.home .. '/.config/hilbish/?.lua'`
preloadPath = "/usr/share/hilbish/preload.lua"
defaultConfDir = "" // ~ will be substituted for home, path for user's default config
sampleConfPath = "/usr/share/hilbish/.hilbishrc.lua" // Path to default/sample config
prompt string // Prompt will always get changed anyway
multilinePrompt = "> "

18
vars_linux.go 100644
View File

@ -0,0 +1,18 @@
// +build linux
package main
// String vars that are free to be changed at compile time
var (
requirePaths = `';./libs/?/init.lua;./?/init.lua;./?/?.lua'
.. ';/usr/share/hilbish/libs/?/init.lua;'
.. ';/usr/share/hilbish/libs/?/?.lua;'
.. hilbish.home .. '/.local/share/hilbish/libs/?/init.lua;'
.. hilbish.home .. '/.local/share/hilbish/libs/?/?.lua;'
.. hilbish.home .. '/.local/share/hilbish/libs/?.lua'
.. hilbish.home .. '/.config/hilbish/?/init.lua'
.. hilbish.home .. '/.config/hilbish/?/?.lua'
.. hilbish.home .. '/.config/hilbish/?.lua'`
preloadPath = "/usr/share/hilbish/preload.lua"
sampleConfPath = "/usr/share/hilbish/.hilbishrc.lua" // Path to default/sample config
)

12
vars_windows.go 100644
View File

@ -0,0 +1,12 @@
// +build windows
package main
// String vars that are free to be changed at compile time
var (
requirePaths = `';./libs/?/init.lua;./?/init.lua;./?/?.lua'
.. hilbish.home .. '\\Appdata\\Roaming\\Hilbish\\libs\\?\\init.lua;'
.. hilbish.home .. '\\Appdata\\Roaming\\Hilbish\\libs\\?\\?.lua;'`
preloadPath = "~\\Appdata\\Roaming\\Hilbish\\preload.lua" // ~ and \ gonna cry?
sampleConfPath = "~\\Appdata\\Roaming\\Hilbish\\hilbishrc.lua" // Path to default/sample config
)