Compare commits

..

No commits in common. "edcc1b39f09dbf9317d1cf4915208f6d1f7c3fdc" and "e37abcb08b0c1f576d981e134797f66943c84ecb" have entirely different histories.

6 changed files with 32 additions and 63 deletions

View File

@ -41,21 +41,11 @@ Then click on the artifacts drop down, and download artifact for your platform,
like what is highlighted in the screenshot.
<br><img src="https://modeus.is-inside.me/KJ0Puceb.png"><br>
### AUR
Arch Linux users can install Hilbish from the AUR.
```sh
yay -S hilbish
```
If you want the latest and greatest, you can install and compile from the latest git commit
```sh
yay -S hilbish-git
```
### Manual Build
#### Prerequisites
- [Go 1.16](https://go.dev)
- GNU Readline
- GNU Readline
On Fedora, readline can be installed with:
```
sudo dnf install readline-devel
@ -71,11 +61,6 @@ On OpenSUSE, it can be installed with:
sudo zypper install readline-devel
```
On Arch Linux, it can be installed with:
```
sudo pacman -S readline
```
#### Build
First, clone Hilbish:
```sh
@ -89,16 +74,23 @@ And get dependencies and build:
```sh
go get -d all
make dev
# If you want to use latest stable release,
make build
# or want to use Hilbiline,
make hilbiline
```
If you `git checkout`'d the latest stable release, run
`make build` instead of `make dev`.
or want to experiment Hilbiline, instead run
`make hilbiline`
#### Install
`sudo make install`
Alternatively, if you use Arch Linux, you can compile Hilbish with an **(unofficial)** AUR package:
```sh
yay -S hilbish
```
If you want the latest and greatest, you can install and compile from latest git commit:
```sh
yay -S hilbish-git
```
### Uninstall
```sh
sudo make uninstall

1
lua.go
View File

@ -42,7 +42,6 @@ func LuaInit() {
cmds := commander.New()
// When a command from Lua is added, register it for use
// TODO: maybe dont add command code to a lua table? insstead use a map
cmds.Events.On("commandRegister",
func(cmdName string, cmd *lua.LFunction) {
commands[cmdName] = true

22
main.go
View File

@ -29,25 +29,17 @@ var (
curuser *user.User
hooks bait.Bait
defaultConfPath string
)
func main() {
homedir, _ = os.UserHomeDir()
curuser, _ = user.Current()
if defaultConfDir == "" {
// we'll add *our* default if its empty (wont be if its changed comptime)
defaultConfPath = filepath.Join(homedir, "/.hilbishrc.lua")
} else {
// else do ~ substitution
defaultConfPath = filepath.Join(strings.Replace(defaultConfDir, "~", homedir, 1), ".hilbishrc.lua")
}
defaultconfpath := homedir + "/.hilbishrc.lua"
verflag := getopt.BoolLong("version", 'v', "Prints Hilbish version")
setshflag := getopt.BoolLong("setshellenv", 'S', "Sets $SHELL to Hilbish's executed path")
cmdflag := getopt.StringLong("command", 'c', "", "Executes a command on startup")
configflag := getopt.StringLong("config", 'C', defaultConfPath, "Sets the path to Hilbish's config")
configflag := getopt.StringLong("config", 'C', defaultconfpath, "Sets the path to Hilbish's config")
getopt.BoolLong("login", 'l', "Makes Hilbish act like a login shell")
getopt.BoolLong("interactive", 'i', "Force Hilbish to be an interactive shell")
getopt.BoolLong("noexec", 'n', "Don't execute and only report Lua syntax errors")
@ -89,21 +81,21 @@ func main() {
}
// If user's config doesn't exixt,
if _, err := os.Stat(defaultConfPath); os.IsNotExist(err) {
if _, err := os.Stat(defaultconfpath); os.IsNotExist(err) {
// Read default from current directory
// (this is assuming the current dir is Hilbish's git)
input, err := os.ReadFile(".hilbishrc.lua")
if err != nil {
// If it wasnt found, go to the real sample conf
input, err = os.ReadFile(sampleConfPath)
// If it wasnt found, go to "real default"
input, err = os.ReadFile("/usr/share/hilbish/.hilbishrc.lua")
if err != nil {
fmt.Println("could not find .hilbishrc.lua or", sampleConfPath)
fmt.Println("could not find .hilbishrc.lua or /usr/share/hilbish/.hilbishrc.lua")
return
}
}
// Create it using either default config we found
err = os.WriteFile(defaultConfPath, input, 0644)
err = os.WriteFile(homedir + "/.hilbishrc.lua", input, 0644)
if err != nil {
// If that fails, bail
fmt.Println("Error creating config file")

View File

@ -35,8 +35,7 @@ commander.register('cd', function (args)
return
end
fs.cd(os.getenv 'HOME')
return
bait.throw('command.exit', 0)
end)
commander.register('exit', function()
@ -47,7 +46,7 @@ do
local virt_G = { }
setmetatable(_G, {
__index = function (_, key)
__index = function (self, key)
local got_virt = virt_G[key]
if got_virt ~= nil then
return got_virt
@ -57,7 +56,7 @@ do
return virt_G[key]
end,
__newindex = function (_, key, value)
__newindex = function (self, key, value)
if type(value) == 'string' then
os.setenv(key, value)
virt_G[key] = value

View File

@ -18,17 +18,6 @@ import (
func RunInput(input string) {
cmdArgs, cmdString := splitInput(input)
// If alias was found, use command alias
for aliases[cmdArgs[0]] != "" {
alias := aliases[cmdArgs[0]]
cmdString = alias + strings.TrimPrefix(cmdString, cmdArgs[0])
cmdArgs, cmdString = splitInput(cmdString)
if aliases[cmdArgs[0]] != "" {
continue
}
}
// First try to load input, essentially compiling to bytecode
fn, err := l.LoadString(cmdString)
if err != nil && noexecute {
@ -160,7 +149,7 @@ func execCommand(cmd string) error {
return interp.NewExitStatus(127)
}
return interp.DefaultExecHandler(2 * time.Second)(ctx, args)
return interp.DefaultExecHandler(2*time.Second)(ctx, args)
}
runner, _ := interp.New(
interp.StdIO(os.Stdin, os.Stdout, os.Stderr),

View File

@ -10,8 +10,6 @@ var (
.. os.getenv 'HOME' .. '/.local/share/hilbish/libs/?/?.lua;'
.. os.getenv 'HOME' .. '/.local/share/hilbish/libs/?.lua'`
preloadPath = "/usr/share/hilbish/preload.lua"
defaultConfDir = "" // ~ will be substituted for home, path for user's default config
sampleConfPath = "/usr/share/hilbish/.hilbishrc.lua" // Path to default/sample config
prompt string // Prompt will always get changed anyway
multilinePrompt = "> "