News for hackers. Stuff that matters.
Re:New(ish) command line tools by yewenjie on Tuesday April 12, 2022 @11:41PM (#31010978)
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?

Re:New(ish) command line tools by faho on Wednesday April 13, 2022 @02:09AM (#31011676)
> 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.

Re:New(ish) command line tools by efreak on Thursday April 14, 2022 @08:35PM (#31035324)
More 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. ```

Re:New(ish) command line tools by stirfish on Wednesday April 13, 2022 @01:09AM (#31011399)
Maybe 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

Mine blinks a little light if a command finishes after 30 seconds, and sends me an email if something takes over a minute.