3 ms·
This is amazing! Is it possible to do the following somehow? - automatically have this for any command that outputs more than 10 lines? - automatically exit w
by yewenjie 5y ago
This is amazing! Is it possible to do the following somehow?
- automatically have this for any command that outputs more than 10 lines?
- automatically exit when the main command (for example a dev server) exits?
- print the output of the main command to stdout after this is done?
- stirfish 5y agoMaybe with some clever use of zsh hooks? Here's a gist for zbell; it uses `preexec` and `precmd` to run something right before a command is executed (`preexec`) and right before the prompt is shown again (`precmd`) https://gist.github.com/jpouellet/5278239 https://gist.github.com/jpouellet/5278239 Mine blinks a little light if a command finishes after 30 seconds, and sends me an email if something takes over a minute.
- faho 5y ago> automatically have this for any command that outputs more than 10 lines? Probably not. The output of a command typically goes directly to the terminal and does not pass through the shell, so the shell has no idea how many lines there are. You could write a shell where that's not the case, but that would have issues with interactive things - what happens if you run e.g. vim or htop in that context? You can pipe to `less -F` (`--quit-if-one-screen`), but note that the version of `less` shipped with macOS has a bug and might just swallow the output instead.
- efreak 5y agoMore likely is a feature to skip processing on short outputs, like `less -F` ``` -F ........ --quit-if-one-screen Quit if entire file fits on first screen. ```