mirror of
https://github.com/Hilbis/Hilbish
synced 2025-04-27 16:03:23 +00:00
28 lines
471 B
Lua
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
|
|
}
|