mirror of
https://github.com/Hilbis/Hilbish
synced 2025-05-12 15:23:23 +00:00
Compare commits
No commits in common. "23f6986123fa2c24d71266ab4ba758c4d8a7ef33" and "a9018a2740954c510109480dceea90055c552460" have entirely different histories.
23f6986123
...
a9018a2740
1
.github/semantic.yml
vendored
1
.github/semantic.yml
vendored
@ -1 +0,0 @@
|
||||
titleAndCommits: true
|
1
TODO.md
1
TODO.md
@ -7,4 +7,3 @@
|
||||
- [x] Hooks
|
||||
- [x] Aliases
|
||||
- [ ] hlua (hilbish lua) - 100% lua in the hilbish interactive shell, cuz why not
|
||||
- [ ] Petals (name of plugins)
|
||||
|
@ -2,7 +2,6 @@ package fs
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/yuin/gopher-lua"
|
||||
)
|
||||
@ -27,7 +26,7 @@ var exports = map[string]lua.LGFunction{
|
||||
func cd(L *lua.LState) int {
|
||||
path := L.ToString(1)
|
||||
|
||||
err := os.Chdir(strings.TrimSpace(path))
|
||||
err := os.Chdir(path)
|
||||
if err != nil {
|
||||
switch err.(*os.PathError).Err.Error() {
|
||||
case "no such file or directory":
|
||||
|
1
main.go
1
main.go
@ -108,7 +108,6 @@ func main() {
|
||||
if err == nil {
|
||||
// If it succeeds, add to history and prompt again
|
||||
readline.AddHistory(cmdString)
|
||||
bait.Em.Emit("command.success", nil)
|
||||
continue
|
||||
}
|
||||
|
||||
|
18
preload.lua
18
preload.lua
@ -5,23 +5,17 @@ local fs = require 'fs'
|
||||
local commander = require 'commander'
|
||||
local bait = require 'bait'
|
||||
|
||||
commander.register('cd', function (args)
|
||||
bait.throw('cd', args)
|
||||
if #args > 0 then
|
||||
local path = ''
|
||||
for i = 1, #args do
|
||||
path = path .. tostring(args[i]) .. ' '
|
||||
end
|
||||
|
||||
local ok, err = pcall(function() fs.cd(path) end)
|
||||
commander.register('cd', function (path)
|
||||
if #path == 1 then
|
||||
local ok, err = pcall(function() fs.cd(path[1]) end)
|
||||
if not ok then
|
||||
if err == 1 then
|
||||
print('directory does not exist')
|
||||
end
|
||||
bait.throw('command.fail', nil)
|
||||
else bait.throw('command.success', nil) end
|
||||
end
|
||||
bait.throw('cd', path)
|
||||
return
|
||||
end
|
||||
fs.cd(os.getenv 'HOME')
|
||||
bait.throw('command.success', nil)
|
||||
bait.throw('cd', path)
|
||||
end)
|
||||
|
Loading…
x
Reference in New Issue
Block a user