mirror of https://github.com/Hilbis/Hilbish
feat: appendpath function
parent
4476a96eec
commit
786b95c266
|
@ -24,22 +24,6 @@ var exports = map[string]lua.LGFunction{
|
|||
"cd": cd,
|
||||
"mkdir": mkdir,
|
||||
"stat": stat,
|
||||
"appendpath": appendpath,
|
||||
}
|
||||
|
||||
func appendpath(L *lua.LState) int {
|
||||
path := L.ToString(1)
|
||||
|
||||
os.Setenv("PATH", os.Getenv("PATH")+":"+path)
|
||||
// cmd := exec.Command("export PATH=" + os.Getenv("PATH") + ":" + path)
|
||||
// shell.execCommand("export PATH=" + os.Getenv("PATH") + ":" + path)
|
||||
|
||||
// fmt.Println(cmd.String())
|
||||
// err := cmd.Run()
|
||||
// if err != nil {
|
||||
// LuaErr(L, 1)
|
||||
// }
|
||||
return 0
|
||||
}
|
||||
|
||||
func cd(L *lua.LState) int {
|
||||
|
|
9
lua.go
9
lua.go
|
@ -27,6 +27,7 @@ func LuaInit(confpath string) {
|
|||
l.SetGlobal("prompt", l.NewFunction(hshprompt))
|
||||
l.SetGlobal("multiprompt", l.NewFunction(hshmlprompt))
|
||||
l.SetGlobal("alias", l.NewFunction(hshalias))
|
||||
l.SetGlobal("appendpath", l.NewFunction(hsappendpath))
|
||||
|
||||
// Add fs module to Lua
|
||||
l.PreloadModule("fs", lfs.Loader)
|
||||
|
@ -99,3 +100,11 @@ func hshalias(L *lua.LState) int {
|
|||
|
||||
return 1
|
||||
}
|
||||
|
||||
func hsappendpath(L *lua.LState) int {
|
||||
path := L.ToString(1)
|
||||
|
||||
os.Setenv("PATH", os.Getenv("PATH")+":"+path)
|
||||
|
||||
return 0
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue