Suspend k9s using CTRL-Z
Description
Implements unix-like suspend functionality mentioned in https://github.com/derailed/k9s/issues/2013
At the moment, k9s supports Ctrl-C, which exits the application, however it's not possible to suspend the process and send it to the background. This PR implements that functionality, which is common among other tools, like vim.
User can now send the process to the background by pressing Ctrl-Z.
Once suspended, it can be resumed by either using fg or selecting a specific id from the jobs list (for example %1) in case there are multiple ones.
This behaviour can be enabled by setting allowSuspend to true.
Changes
- remapped "Toggle Faults" action from Ctrl-Z to Ctrl-T (first one available that kind of made sense to me)
- added suspend functionality to Ctrl-Z, which sends
SIGTSTPsignal to the current k9s process - added
allowSuspendconfig to opt in to this behaviour - updated tests
TODO:
- [x] test on other platforms
Notes
This is my first contribution to this project, so happy to update things if there's anything missing/required. Thanks!
@derailed seems like go doesn't support os signals on Windows without some hacky workarounds.
I was thinking about spawning a shell for anything other than linux and darwin OS.
From a user perspective it's going to look almost the same, except in order to return to k9s, you'll need to exit the shell instead of resuming the process from the background. Let me know if that makes sense.
Otherwise we can go with the subshell approach for everyone.
@arajski Thank you for the research Artur! I think for non nix users likely Ctrtl-z does not make much sense. I don't use windows much these days but isn't Ctrl-z equivalent to undo?
If so might be best to detect the os and disable that functionality while in windows land?
Done :+1: Tested on macOS Sonoma and Debian 12