2
2
Mirror von https://github.com/Hilbis/Hilbish synchronisiert 2025-07-06 02:52:02 +00:00

Commits vergleichen

...

3 Commits

Autor SHA1 Nachricht Datum
TorchedSammy
bbfe28dbae chore: fix formatting and add comma 2021-04-07 09:18:06 -04:00
devins2518
140bdeebd7
chore: fix default luarc grammar (#24) 2021-04-07 09:10:11 -04:00
TorchedSammy
0fa3d50db7 feat: add -C flag (closes #20) 2021-04-07 08:40:40 -04:00
3 geänderte Dateien mit 15 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -8,9 +8,9 @@ function doPrompt(fail)
)) ))
end end
print(ansikit.format('Welcome {cyan}'.. os.getenv 'USER' .. print(ansikit.format('Welcome to {magenta}Hilbish{reset}, {cyan}' ..
'{reset} to {magenta}Hilbish{reset},\n' .. os.getenv 'USER' .. '{reset}.\n' ..
'the nice lil shell for {blue}Lua{reset} fanatics!\n')) 'The nice lil shell for {blue}Lua{reset} fanatics!\n'))
doPrompt() doPrompt()

5
lua.go
Datei anzeigen

@ -17,7 +17,7 @@ prompt(ansikit.format(
)) ))
` `
func LuaInit() { func LuaInit(confpath string) {
l = lua.NewState() l = lua.NewState()
l.OpenLibs() l.OpenLibs()
@ -60,9 +60,8 @@ func LuaInit() {
} }
} }
homedir, _ := os.UserHomeDir()
// Run config // Run config
err = l.DoFile(homedir + "/.hilbishrc.lua") err = l.DoFile(confpath)
if err != nil { if err != nil {
fmt.Fprintln(os.Stderr, err, fmt.Fprintln(os.Stderr, err,
"\nAn error has occured while loading your config! Falling back to minimal default config.\n") "\nAn error has occured while loading your config! Falling back to minimal default config.\n")

13
main.go
Datei anzeigen

@ -31,6 +31,9 @@ var bait hooks.Bait
var homedir string var homedir string
func main() { func main() {
homedir, _ = os.UserHomeDir()
defaultconfpath := homedir + "/.hilbishrc.lua"
parser := argparse.NewParser("hilbish", "A shell for lua and flower lovers") parser := argparse.NewParser("hilbish", "A shell for lua and flower lovers")
verflag := parser.Flag("v", "version", &argparse.Options{ verflag := parser.Flag("v", "version", &argparse.Options{
Required: false, Required: false,
@ -40,6 +43,11 @@ func main() {
Required: false, Required: false,
Help: "Sets $SHELL to Hilbish's executed path", Help: "Sets $SHELL to Hilbish's executed path",
}) })
configflag := parser.String("C", "config", &argparse.Options{
Required: false,
Help: "Sets the path to Hilbish's config",
Default: defaultconfpath,
})
err := parser.Parse(os.Args) err := parser.Parse(os.Args)
// If invalid flags or --help/-h, // If invalid flags or --help/-h,
@ -57,9 +65,8 @@ func main() {
// Set $SHELL if the user wants to // Set $SHELL if the user wants to
if *setshflag { os.Setenv("SHELL", os.Args[0]) } if *setshflag { os.Setenv("SHELL", os.Args[0]) }
homedir, _ = os.UserHomeDir()
// If user's config doesn't exixt, // If user's config doesn't exixt,
if _, err := os.Stat(homedir + "/.hilbishrc.lua"); os.IsNotExist(err) { if _, err := os.Stat(defaultconfpath); os.IsNotExist(err) {
// Read default from current directory // Read default from current directory
// (this is assuming the current dir is Hilbish's git) // (this is assuming the current dir is Hilbish's git)
input, err := os.ReadFile(".hilbishrc.lua") input, err := os.ReadFile(".hilbishrc.lua")
@ -83,7 +90,7 @@ func main() {
} }
HandleSignals() HandleSignals()
LuaInit() LuaInit(*configflag)
readline.Completer = readline.FilenameCompleter readline.Completer = readline.FilenameCompleter
readline.LoadHistory(homedir + "/.hilbish-history") readline.LoadHistory(homedir + "/.hilbish-history")