mirror of https://github.com/Hilbis/Hilbish
Compare commits
No commits in common. "bbfe28dbae23bbf6257d9bfb0f8bc4c0975220b1" and "51bcc516876a6b5d3cca014d9150ea3080e30654" have entirely different histories.
bbfe28dbae
...
51bcc51687
|
@ -8,9 +8,9 @@ function doPrompt(fail)
|
||||||
))
|
))
|
||||||
end
|
end
|
||||||
|
|
||||||
print(ansikit.format('Welcome to {magenta}Hilbish{reset}, {cyan}' ..
|
print(ansikit.format('Welcome {cyan}'.. os.getenv 'USER' ..
|
||||||
os.getenv 'USER' .. '{reset}.\n' ..
|
'{reset} to {magenta}Hilbish{reset},\n' ..
|
||||||
'The nice lil shell for {blue}Lua{reset} fanatics!\n'))
|
'the nice lil shell for {blue}Lua{reset} fanatics!\n'))
|
||||||
|
|
||||||
doPrompt()
|
doPrompt()
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,7 @@ ansikit.saveState = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
ansikit.setTitle = function(text)
|
ansikit.setTitle = function(text)
|
||||||
return ansikit.printCode(']2;' .. text, true)
|
ansikit.printCode (']2;' .. text, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
ansikit.showCursor = function()
|
ansikit.showCursor = function()
|
||||||
|
|
5
lua.go
5
lua.go
|
@ -17,7 +17,7 @@ prompt(ansikit.format(
|
||||||
))
|
))
|
||||||
`
|
`
|
||||||
|
|
||||||
func LuaInit(confpath string) {
|
func LuaInit() {
|
||||||
l = lua.NewState()
|
l = lua.NewState()
|
||||||
|
|
||||||
l.OpenLibs()
|
l.OpenLibs()
|
||||||
|
@ -60,8 +60,9 @@ func LuaInit(confpath string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
homedir, _ := os.UserHomeDir()
|
||||||
// Run config
|
// Run config
|
||||||
err = l.DoFile(confpath)
|
err = l.DoFile(homedir + "/.hilbishrc.lua")
|
||||||
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")
|
||||||
|
|
19
main.go
19
main.go
|
@ -14,7 +14,7 @@ import (
|
||||||
"github.com/akamensky/argparse"
|
"github.com/akamensky/argparse"
|
||||||
"github.com/bobappleyard/readline"
|
"github.com/bobappleyard/readline"
|
||||||
"github.com/yuin/gopher-lua"
|
"github.com/yuin/gopher-lua"
|
||||||
"golang.org/x/term"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "0.3.1"
|
const version = "0.3.1"
|
||||||
|
@ -31,9 +31,6 @@ 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,
|
||||||
|
@ -43,11 +40,6 @@ 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,
|
||||||
|
@ -65,8 +57,9 @@ 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(defaultconfpath); os.IsNotExist(err) {
|
if _, err := os.Stat(homedir + "/.hilbishrc.lua"); 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")
|
||||||
|
@ -90,7 +83,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleSignals()
|
HandleSignals()
|
||||||
LuaInit(*configflag)
|
LuaInit()
|
||||||
|
|
||||||
readline.Completer = readline.FilenameCompleter
|
readline.Completer = readline.FilenameCompleter
|
||||||
readline.LoadHistory(homedir + "/.hilbish-history")
|
readline.LoadHistory(homedir + "/.hilbish-history")
|
||||||
|
@ -118,10 +111,6 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RunInput(input)
|
RunInput(input)
|
||||||
|
|
||||||
termwidth, _, err := term.GetSize(0)
|
|
||||||
if err != nil { continue }
|
|
||||||
fmt.Printf("\u001b[7m∆\u001b[0m" + strings.Repeat(" ", termwidth - 1) + "\r")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue