mirror of
https://github.com/Hilbis/Hilbish
synced 2025-04-21 04:53:24 +00:00
27 lines
445 B
Lua
27 lines
445 B
Lua
local fs = require 'fs'
|
|
|
|
hilbish.processors.add {
|
|
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
|
|
}
|