summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeLines
* bin/ovr: Add copyleftHEADmainAlejandro Colomar2023-10-11-0/+4
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/ovr: Remove useless initializationAlejandro Colomar2023-10-11-2/+0
| | | | | Cc: Kamil Maciorowski <https://linux.codidact.com/users/62405> Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/ovr: --no-alt: Don't overwrite stderrAlejandro Colomar2023-10-10-2/+2
| | | | | | | | | Move part of the escape sequence to the end of stdout lines, instead of the begining of lines, so that a stdout line won't overwrite the previous line if it comes from stderr. Instead, a stderr line coming after a stdout one will overwrite it. Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/ovr: --no-alt: Use setterm --linewrap off to trim long linesAlejandro Colomar2023-10-10-2/+4
| | | | | | This is more reliable, and probably faster, than using sed(1). Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/ovr, share/man/man1/ovr.1: --no-alt: Add option to not use the alternate ↵Alejandro Colomar2023-10-10-1/+24
| | | | | | | | screen In some cases, it might be simpler to use normal stdout. Signed-off-by: Alejandro Colomar <alx@kernel.org>
* fAlejandro Colomar2023-10-10-1/+1
|
* bin/ovr: srcfix: Move code to functionAlejandro Colomar2023-10-10-12/+17
| | | | | | | This will allow adding a --no-alt mode that doesn't use the alternate screen. Signed-off-by: Alejandro Colomar <alx@kernel.org>
* share/man/man1/ovr.1: Add manual pageAlejandro Colomar2023-10-10-0/+80
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/ovr: Wrap linesAlejandro Colomar2023-10-10-2/+2
| | | | | | | Prompts that are longer than the terminal become unreadable if there's no wrapping. Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/ovr: -n, --lines: Add option to control permanent linesAlejandro Colomar2023-10-10-4/+33
| | | | | | | | | | This was previously accepted as a positional argument, but an option is more conventional. Use the same option name as tail(1), since we just pass it directly to tail(1). Rename the old $lines variable to $permanent, to avoid confusion. Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/ovr: srcfix: Add trailing ';'sAlejandro Colomar2023-10-10-10/+10
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/ovr: chmod +rAlejandro Colomar2023-10-10-0/+0
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/ovr: Use the "alternate screen"Alejandro Colomar2023-10-10-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Kamil said: > [This] script switches the terminal to the alternate screen and pipes > its input there. Eventually it switches the terminal back. Then it > prints (repeats) one last line to its stdout, this is the line that > will remain. > [...] > > Notes: > > - The script uses at most one argument. If specified, the argument > is passed to `tail -n`. This way you can get more than one last > line in your normal screen. If not specified, `1` is used. > > - `tput smcup` and `tput rmcup` are responsible for entering and > leaving the alternate screen respectively. > > - `setterm --linewrap off` tells the terminal not to wrap long lines. > You may prefer not using `setterm --linewrap off` and > `setterm --linewrap on` in the script. Delete them at will. > > - The last line(s) is printed (repeated) outside of the alternate > screen in full, i.e. with wrapping. > > - Tools that read from the terminal (sudo(8) asking for password, > simple y/n prompts) should work in the alternate screen. > > - The script will not capture your input (like an answer to a y/n > prompt) to print (repeat) it after leaving the alternate screen, > even if the input is echoed inside the alternate screen and seems > to belong to the last line(s). > > - Tools that print directly to the terminal (/dev/tty) or to their > stdout (which happens to be the terminal) should work in the > alternate screen, but such lines will not be among lines captured > by the script and repeated after leaving the alternate screen. > Inside the alternate screen such lines may seem out of sync with > respect to stdout because only stdout is "delayed" and buffered > around tee. > > - If you want, you can merge stderr with stdout and pipe the merged > stream to the script: `something 2>&1 | ovr`. This way, stdout and > stderr will stay in sync. > > - The script works reasonably well when the pipeline gets interrupted > with Ctrl+c. > > - Ctrl+z is somewhat troublesome because the script will stop without > leaving the alternate screen. If you make it continue in the > foreground (fg(1)) then it will leave the alternate screen > eventually like it normally would. If you kill it with SIGTERM > (`kill %%`) then it will leave the alternate screen because of the > trap. Developed-by: Kamil Maciorowski <https://linux.codidact.com/users/62405> Link: <https://linux.codidact.com/posts/289869/289899#answer-289899> Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/ovr: Truncate lines at `tput cols`Alejandro Colomar2023-10-09-1/+2
| | | | | | | | | This improves the behavior with long input lines. There are still glitches, though. Co-developed-by: r~~ <https://linux.codidact.com/users/53410> Link: <https://linux.codidact.com/posts/289869/289875#answer-289875> Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/ovr: Add initial implementationAlejandro Colomar2023-10-09-0/+3
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* nullAlejandro Colomar2023-10-09-0/+0
Signed-off-by: Alejandro Colomar <alx@kernel.org>