Closed zhengpd closed 1 year ago
For example, here's what I do with FTerm for now to only close window on exit code 0:
local open_cmd = function(cmd)
local term = require('FTerm'):new({
cmd = cmd,
auto_close = false,
dimensions = { height = 1, width = 1 }
})
term.config.on_exit = function(job_id, code, event)
if code == 0 then term:close(true) end
end
term:open()
end
The on_exit
seems not supporting self:close
so I have to split config.on_exit
away from :new
call.
So I suggest we can keep the terminal window if cmd didn't exit with code 0.
I think your assessment is right. It would also be helpful in seeing the error message if the command didn't succeed.
Apologies for coming so late on this. Now this should be the default behavior. Ref: https://github.com/numToStr/FTerm.nvim/commit/a798d1c0a54ff35257cad17b448c783028b8437b
@numToStr 👍 This could be really helpful.
Currently, when
auto_close = true
, FTerm always close window after cmd finished, success or failure. I think it's useful to check the error msg if a cmd failed. So I suggest we can keep the terminal window if cmd didn't exit with code 0.