2
2
mirror of https://github.com/Hilbis/Hilbish synced 2025-06-14 08:22:04 +00:00
Hilbish/nature/opts/autocd.lua
sammyette 1bb433dc64
feat: add processors api (#343)
* feat: add processors api

* fix: make processor work properly, implement in exec code

* feat: add names to processors, allow skipping based on name

* feat: add opt to skip processors

* feat: allow processors to set if history should be saved
2025-06-10 18:23:24 -04:00

28 lines
471 B
Lua

local fs = require 'fs'
hilbish.processors.add {
name = 'hilbish.autocd',
func = function(path)
if hilbish.opts.autocd then
local ok, stat = pcall(fs.stat, path)
if ok and stat.isDir then
local oldPath = hilbish.cwd()
local absPath = fs.abs(path)
fs.cd(path)
bait.throw('cd', path, oldPath)
bait.throw('hilbish.cd', absPath, oldPath)
end
return {
continue = not ok
}
else
return {
continue = true
}
end
end
}