Compare commits

...

4 Commits

Author SHA1 Message Date
Will Eccles e34ab5314a
fix: make macOS config path match Linux (#143)
Also moves some variables around in vars_*.go to accommodate the fix.
2022-04-19 22:12:05 -04:00
TorchedSammy 0ae31123b9
fix: make expand home actually expand and not do the opposite 2022-04-19 22:05:48 -04:00
TorchedSammy 7a17d7931f
fix: use load from source in DoFile function instead of load chunk 2022-04-19 21:25:52 -04:00
TorchedSammy d4084a82ba
fix: expandHome function using hist dir instead of passed arg 2022-04-19 21:23:48 -04:00
6 changed files with 9 additions and 8 deletions

View File

@ -44,7 +44,7 @@ func main() {
// i honestly dont know what directories to use for this
switch runtime.GOOS {
case "linux":
case "linux", "darwin":
userDataDir = getenv("XDG_DATA_HOME", curuser.HomeDir + "/.local/share")
default:
// this is fine on windows, dont know about others
@ -56,7 +56,7 @@ func main() {
defaultConfDir = filepath.Join(confDir, "hilbish")
} else {
// else do ~ substitution
defaultConfDir = expandHome(defaultHistDir)
defaultConfDir = filepath.Join(expandHome(defaultConfDir), "hilbish")
}
defaultConfPath = filepath.Join(defaultConfDir, "init.lua")
if defaultHistDir == "" {
@ -275,8 +275,7 @@ func handleHistory(cmd string) {
func expandHome(path string) string {
homedir := curuser.HomeDir
return strings.Replace(defaultHistDir, "~", homedir, 1)
return strings.Replace(path, "~", homedir, 1)
}
func removeDupes(slice []string) []string {

View File

@ -93,9 +93,9 @@ func DoFile(rtm *rt.Runtime, path string) error {
buf = append(buf, line...)
}
chunk, err := rtm.CompileAndLoadLuaChunk(path, buf, rt.TableValue(rtm.GlobalEnv()))
if chunk != nil {
_, err = rt.Call1(rtm.MainThread(), rt.FunctionValue(chunk))
clos, err := rtm.LoadFromSourceOrCode(path, buf, "bt", rt.TableValue(rtm.GlobalEnv()), false)
if clos != nil {
_, err = rt.Call1(rtm.MainThread(), rt.FunctionValue(clos))
}
return err

View File

@ -3,7 +3,6 @@ package main
// String vars that are free to be changed at compile time
var (
version = "v2.0.0"
defaultConfDir = "" // ~ will be substituted for home, path for user's default config
defaultHistDir = ""
commonRequirePaths = "';./libs/?/init.lua;./?/init.lua;./?/?.lua'"

View File

@ -17,4 +17,5 @@ var (
dataDir = "/usr/local/share/hilbish"
preloadPath = dataDir + "/prelude/init.lua"
sampleConfPath = dataDir + "/.hilbishrc.lua" // Path to default/sample config
defaultConfDir = getenv("XDG_CONFIG_HOME", "~/.config")
)

View File

@ -17,4 +17,5 @@ var (
dataDir = "/usr/share/hilbish"
preloadPath = dataDir + "/prelude/init.lua"
sampleConfPath = dataDir + "/.hilbishrc.lua" // Path to default/sample config
defaultConfDir = ""
)

View File

@ -11,4 +11,5 @@ var (
dataDir = "~\\Appdata\\Roaming\\Hilbish" // ~ and \ gonna cry?
preloadPath = dataDir + "\\prelude\\init.lua"
sampleConfPath = dataDir + "\\hilbishrc.lua" // Path to default/sample config
defaultConfDir = ""
)