diff --git a/.hilbishrc.lua b/.hilbishrc.lua index b51db8f..4706937 100644 --- a/.hilbishrc.lua +++ b/.hilbishrc.lua @@ -9,7 +9,7 @@ function doPrompt(fail) end print(ansikit.format('Welcome to {magenta}Hilbish{reset}, {cyan}' .. -os.getenv 'USER' .. '{reset}.\n' .. +_user .. '{reset}.\n' .. 'The nice lil shell for {blue}Lua{reset} fanatics!\n')) doPrompt() diff --git a/lua.go b/lua.go index 5b6eb79..bb0a9f8 100644 --- a/lua.go +++ b/lua.go @@ -23,6 +23,7 @@ func LuaInit() { l.OpenLibs() l.SetGlobal("_ver", lua.LString(version)) + l.SetGlobal("_user", lua.LString(curuser.Username)) l.SetGlobal("prompt", l.NewFunction(hshprompt)) l.SetGlobal("multiprompt", l.NewFunction(hshmlprompt)) diff --git a/main.go b/main.go index 7c27d59..b4926ac 100644 --- a/main.go +++ b/main.go @@ -4,9 +4,10 @@ import ( "fmt" "io" "os" + "strings" "os/signal" "os/user" - "strings" + "path/filepath" "hilbish/golibs/bait" @@ -27,15 +28,18 @@ var ( commands = map[string]bool{} aliases = map[string]string{} - hooks bait.Bait homedir string + curuser *user.User + running bool // Is a command currently running + hooks bait.Bait interactive bool login bool // Are we the login shell? ) func main() { homedir, _ = os.UserHomeDir() + curuser, _ = user.Current() defaultconfpath := homedir + "/.hilbishrc.lua" // parser := argparse.NewParser("hilbish", "A shell for lua and flower lovers") @@ -169,16 +173,16 @@ func ContinuePrompt(prev string) (string, error) { // This semi cursed function formats our prompt (obviously) func fmtPrompt() string { - user, _ := user.Current() host, _ := os.Hostname() cwd, _ := os.Getwd() - cwd = strings.Replace(cwd, user.HomeDir, "~", 1) + cwd = strings.Replace(cwd, curuser.HomeDir, "~", 1) args := []string{ "d", cwd, + "D", filepath.Base(cwd), "h", host, - "u", user.Username, + "u", curuser.Username, } for i, v := range args {