Post History
Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them. This has the benefit that s...
Answer
#20: Post edited
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- setterm --linewrap off;
- sed -e '$ ! s/$/\x1B[1A/' \
- -e '2,$ s/^/\x1B[K/';
- setterm --linewrap on;
- ```
- This uses `setterm --linewrap off` to reliably trim long lines, as learnt from [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899).
- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo\nbar' | ovr --no-alt
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ovr --no-alt
- foo
- $ echo '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o' | ovr --no-alt
- 123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789o
- ```
- (I did actually implement it as an option to a script that can also use alternate screen as in [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899), so I can choose; thus the `--no-alt` option.)
- This implementation is much simpler than using the alternate screen.
A disadvantage is that it's not possible to set the number of lines to keep. If that's wanted, you can maybe pipe with pee(1):- ```sh
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | pee "ovr --no-alt" "tail -n2"
- e
- xxxxx
- bz
- bar
- bz
- ```
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- setterm --linewrap off;
- sed -e '$ ! s/$/\x1B[1A/' \
- -e '2,$ s/^/\x1B[K/';
- setterm --linewrap on;
- ```
- This uses `setterm --linewrap off` to reliably trim long lines, as learnt from [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899).
- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo\nbar' | ovr --no-alt
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ovr --no-alt
- foo
- $ echo '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o' | ovr --no-alt
- 123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789o
- ```
- (I did actually implement it as an option to a script that can also use alternate screen as in [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899), so I can choose; thus the `--no-alt` option.)
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep. If that's wanted, you can pipe also to tail(1) with pee(1):
- ```sh
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | pee "ovr --no-alt" "tail -n2"
- e
- xxxxx
- bz
- bar
- bz
- ```
#19: Post edited
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- setterm --linewrap off;
- sed -e '$ ! s/$/\x1B[1A/' \
- -e '2,$ s/^/\x1B[K/';
- setterm --linewrap on;
- ```
- This uses `setterm --linewrap off` to reliably trim long lines, as learnt from [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899).
- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo\nbar' | ovr --no-alt
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ovr --no-alt
- foo
- $ echo '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o' | ovr --no-alt
- 123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789o
- ```
- (I did actually implement it as an option to a script that can also use alternate screen as in [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899), so I can choose; thus the `--no-alt` option.)
- This implementation is much simpler than using the alternate screen.
A disadvantage is that it's not possible to set the number of lines to keep.
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- setterm --linewrap off;
- sed -e '$ ! s/$/\x1B[1A/' \
- -e '2,$ s/^/\x1B[K/';
- setterm --linewrap on;
- ```
- This uses `setterm --linewrap off` to reliably trim long lines, as learnt from [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899).
- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo\nbar' | ovr --no-alt
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ovr --no-alt
- foo
- $ echo '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o' | ovr --no-alt
- 123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789o
- ```
- (I did actually implement it as an option to a script that can also use alternate screen as in [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899), so I can choose; thus the `--no-alt` option.)
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep. If that's wanted, you can maybe pipe with pee(1):
- ```sh
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | pee "ovr --no-alt" "tail -n2"
- e
- xxxxx
- bz
- bar
- bz
- ```
#18: Post edited
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- setterm --linewrap off;
- sed -e '$ ! s/$/\x1B[1A/' \
- -e '2,$ s/^/\x1B[K/';
- setterm --linewrap on;
- ```
- This uses `setterm --linewrap off` to reliably trim long lines, as learnt from [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899).
- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo\nbar' | ovr --no-alt
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ovr --no-alt
- foo
- ```
- (I did actually implement it as an option to a script that can also use alternate screen as in [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899), so I can choose; thus the `--no-alt` option.)
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep.
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- setterm --linewrap off;
- sed -e '$ ! s/$/\x1B[1A/' \
- -e '2,$ s/^/\x1B[K/';
- setterm --linewrap on;
- ```
- This uses `setterm --linewrap off` to reliably trim long lines, as learnt from [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899).
- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo\nbar' | ovr --no-alt
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ovr --no-alt
- foo
- $ echo '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o' | ovr --no-alt
- 123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789o
- ```
- (I did actually implement it as an option to a script that can also use alternate screen as in [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899), so I can choose; thus the `--no-alt` option.)
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep.
#17: Post edited
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- setterm --linewrap off;
- sed -e '$ ! s/$/\x1B[1A/' \
- -e '2,$ s/^/\x1B[K/';
- setterm --linewrap on;
- ```
- This uses `setterm --linewrap off` to reliably trim long lines, as learnt from [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899).
- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo\nbar' | ovr --no-alt
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
$ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789ofoo' | ./bin/ovr --no-alt- foo
- ```
- (I did actually implement it as an option to a script that can also use alternate screen as in [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899), so I can choose; thus the `--no-alt` option.)
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep.
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- setterm --linewrap off;
- sed -e '$ ! s/$/\x1B[1A/' \
- -e '2,$ s/^/\x1B[K/';
- setterm --linewrap on;
- ```
- This uses `setterm --linewrap off` to reliably trim long lines, as learnt from [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899).
- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo\nbar' | ovr --no-alt
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o
- foo' | ovr --no-alt
- foo
- ```
- (I did actually implement it as an option to a script that can also use alternate screen as in [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899), so I can choose; thus the `--no-alt` option.)
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep.
#16: Post edited
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- setterm --linewrap off;
- sed -e '$ ! s/$/\x1B[1A/' \
- -e '2,$ s/^/\x1B[K/';
- setterm --linewrap on;
- ```
This already includes the improvements from [this answer](https://linux.codidact.com/posts/289869/289875#answer-289875).- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo\nbar' | ovr --no-alt
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ./bin/ovr --no-alt
- foo
- ```
- (I did actually implement it as an option to a script that can also use alternate screen as in [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899), so I can choose; thus the `--no-alt` option.)
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep.
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- setterm --linewrap off;
- sed -e '$ ! s/$/\x1B[1A/' \
- -e '2,$ s/^/\x1B[K/';
- setterm --linewrap on;
- ```
- This uses `setterm --linewrap off` to reliably trim long lines, as learnt from [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899).
- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo\nbar' | ovr --no-alt
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ./bin/ovr --no-alt
- foo
- ```
- (I did actually implement it as an option to a script that can also use alternate screen as in [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899), so I can choose; thus the `--no-alt` option.)
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep.
#15: Post edited
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- setterm --linewrap off;
- sed -e '$ ! s/$/\x1B[1A/' \
- -e '2,$ s/^/\x1B[K/';
- setterm --linewrap on;
- ```
- This already includes the improvements from [this answer](https://linux.codidact.com/posts/289869/289875#answer-289875).
- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo\nbar' | ovr --no-alt
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ./bin/ovr --no-alt
- foo
- ```
- (I did actually implement it as an option to a script that can also use alternate screen as in [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899), so I can choose; thus the `--no-alt` option.)
- This implementation is much simpler than using the alternate screen.
A disadvantage is that it's not possible to set the number of lines to keep. And it still has the issue that tabs or other characters may take up a number of columns different than 1.
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- setterm --linewrap off;
- sed -e '$ ! s/$/\x1B[1A/' \
- -e '2,$ s/^/\x1B[K/';
- setterm --linewrap on;
- ```
- This already includes the improvements from [this answer](https://linux.codidact.com/posts/289869/289875#answer-289875).
- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo\nbar' | ovr --no-alt
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ./bin/ovr --no-alt
- foo
- ```
- (I did actually implement it as an option to a script that can also use alternate screen as in [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899), so I can choose; thus the `--no-alt` option.)
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep.
#14: Post edited
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
sed -e "s/^\(.\{,$(tput cols)\}\).*$/\1/" \-e '$ ! s/$/\x1B[1A/' \- -e '2,$ s/^/\x1B[K/';
- ```
- This already includes the improvements from [this answer](https://linux.codidact.com/posts/289869/289875#answer-289875).
- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo\nbar' | ovr --no-alt
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ./bin/ovr --no-alt
- foo
- ```
- (I did actually implement it as an option to a script that can also use alternate screen as in [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899), so I can choose; thus the `--no-alt` option.)
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep. And it still has the issue that tabs or other characters may take up a number of columns different than 1.
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- setterm --linewrap off;
- sed -e '$ ! s/$/\x1B[1A/' \
- -e '2,$ s/^/\x1B[K/';
- setterm --linewrap on;
- ```
- This already includes the improvements from [this answer](https://linux.codidact.com/posts/289869/289875#answer-289875).
- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo\nbar' | ovr --no-alt
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ./bin/ovr --no-alt
- foo
- ```
- (I did actually implement it as an option to a script that can also use alternate screen as in [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899), so I can choose; thus the `--no-alt` option.)
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep. And it still has the issue that tabs or other characters may take up a number of columns different than 1.
#13: Post edited
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- sed -e "s/^\(.\{,$(tput cols)\}\).*$/\1/" \
- -e '$ ! s/$/\x1B[1A/' \
- -e '2,$ s/^/\x1B[K/';
- ```
- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo\nbar' | ovr --no-alt
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ./bin/ovr --no-alt
- foo
- ```
- (I did actually implement it as an option to a script that can also use alternate screen as in [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899), so I can choose; thus the `--no-alt` option.)
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep. And it still has the issue that tabs or other characters may take up a number of columns different than 1.
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- sed -e "s/^\(.\{,$(tput cols)\}\).*$/\1/" \
- -e '$ ! s/$/\x1B[1A/' \
- -e '2,$ s/^/\x1B[K/';
- ```
- This already includes the improvements from [this answer](https://linux.codidact.com/posts/289869/289875#answer-289875).
- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo\nbar' | ovr --no-alt
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ./bin/ovr --no-alt
- foo
- ```
- (I did actually implement it as an option to a script that can also use alternate screen as in [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899), so I can choose; thus the `--no-alt` option.)
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep. And it still has the issue that tabs or other characters may take up a number of columns different than 1.
#12: Post edited
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- sed -e "s/^\(.\{,$(tput cols)\}\).*$/\1/" \
- -e '$ ! s/$/\x1B[1A/' \
- -e '2,$ s/^/\x1B[K/';
- ```
- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo\nbar' | ovr --no-alt
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ./bin/ovr --no-alt
- foo
- ```
(I did actually implement it as an option to a script that can also use alternate screen, so I can choose; thus the `--no-alt` option.)- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep. And it still has the issue that tabs or other characters may take up a number of columns different than 1.
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- sed -e "s/^\(.\{,$(tput cols)\}\).*$/\1/" \
- -e '$ ! s/$/\x1B[1A/' \
- -e '2,$ s/^/\x1B[K/';
- ```
- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo\nbar' | ovr --no-alt
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ./bin/ovr --no-alt
- foo
- ```
- (I did actually implement it as an option to a script that can also use alternate screen as in [this other answer](https://linux.codidact.com/posts/289869/289899#answer-289899), so I can choose; thus the `--no-alt` option.)
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep. And it still has the issue that tabs or other characters may take up a number of columns different than 1.
#11: Post edited
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- sed -e "s/^\(.\{,$(tput cols)\}\).*$/\1/" \
- -e '$ ! s/$/\x1B[1A/' \
- -e '2,$ s/^/\x1B[K/';
- ```
- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo\nbar' | ovr --no-alt
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ./bin/ovr --no-alt
- foo
- ```
(I did actually implement it as an option to a script that can also use alternate screen, so I can choose; thus the --no-alt option.)- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep. And it still has the issue that tabs or other characters may take up a number of columns different than 1.
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- sed -e "s/^\(.\{,$(tput cols)\}\).*$/\1/" \
- -e '$ ! s/$/\x1B[1A/' \
- -e '2,$ s/^/\x1B[K/';
- ```
- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo\nbar' | ovr --no-alt
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ./bin/ovr --no-alt
- foo
- ```
- (I did actually implement it as an option to a script that can also use alternate screen, so I can choose; thus the `--no-alt` option.)
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep. And it still has the issue that tabs or other characters may take up a number of columns different than 1.
#10: Post edited
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- sed -e "s/^\(.\{,$(tput cols)\}\).*$/\1/" \
- -e '$ ! s/$/\x1B[1A/' \
- -e '2,$ s/^/\x1B[K/';
- ```
- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo\nbar' | ovr --no-alt
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ./bin/ovr --no-alt
- foo
- ```
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep. And it still has the issue that tabs or other characters may take up a number of columns different than 1.
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- sed -e "s/^\(.\{,$(tput cols)\}\).*$/\1/" \
- -e '$ ! s/$/\x1B[1A/' \
- -e '2,$ s/^/\x1B[K/';
- ```
- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo\nbar' | ovr --no-alt
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ./bin/ovr --no-alt
- foo
- ```
- (I did actually implement it as an option to a script that can also use alternate screen, so I can choose; thus the --no-alt option.)
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep. And it still has the issue that tabs or other characters may take up a number of columns different than 1.
#9: Post edited
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- sed -e "s/^\(.\{,$(tput cols)\}\).*$/\1/" \
-e '$ ! s/$/\x1B[1A\x1B[K/';- ```
- ```sh
$ echo | ovr$ echo foo | ovr- foo
$ echo -e 'foobar' | ovr- bar
$ echo -e 'foobarbaz' | ovr- baz
$ echo -e 'foobarbaz' | ovr | wc -l1$ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bazz) | ovr- e
- xxxxx
bazz- ```
- This implementation is much simpler than using the alternate screen.
A disadvantage is that it's not possible to set the number of lines to keep.
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- sed -e "s/^\(.\{,$(tput cols)\}\).*$/\1/" \
- -e '$ ! s/$/\x1B[1A/' \
- -e '2,$ s/^/\x1B[K/';
- ```
- ```sh
- $ echo | ovr --no-alt
- $ echo foo | ovr --no-alt
- foo
- $ echo -e 'foo
- bar' | ovr --no-alt
- bar
- $ echo -e 'foo
- bar
- baz' | ovr --no-alt
- baz
- $ echo -e 'foo
- bar
- baz' | ovr --no-alt | wc -l
- 3
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bz) | ovr --no-alt
- e
- xxxxx
- bz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ./bin/ovr --no-alt
- foo
- ```
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep. And it still has the issue that tabs or other characters may take up a number of columns different than 1.
#6: Post edited
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
sed '$ ! s/$/\x1B[1A\x1B[K/';- ```
Note that it doesn't seem to need to trim lines to keep it working.- ```sh
- $ echo | ovr
- $ echo foo | ovr
- foo
- $ echo -e 'foo\nbar' | ovr
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr | wc -l
- 1
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bazz) | ovr
- e
- xxxxx
- bazz
$ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ovrfoo- ```
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep.
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- sed -e "s/^\(.\{,$(tput cols)\}\).*$/\1/" \
- -e '$ ! s/$/\x1B[1A\x1B[K/';
- ```
- ```sh
- $ echo | ovr
- $ echo foo | ovr
- foo
- $ echo -e 'foo\nbar' | ovr
- bar
- $ echo -e 'foo\nbar\nbaz' | ovr
- baz
- $ echo -e 'foo\nbar\nbaz' | ovr | wc -l
- 1
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bazz) | ovr
- e
- xxxxx
- bazz
- ```
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep.
#5: Post edited
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- sed '$ ! s/$/\x1B[1A\x1B[K/';
- ```
- Note that it doesn't seem to need to trim lines to keep it working.
- ```sh
$ echo | ./bin/ovr$ echo foo | ./bin/ovr- foo
$ echo -e 'foobar' | ./bin/ovr- bar
$ echo -e 'foobarbaz' | ./bin/ovr- baz
$ echo -e 'foobarbaz' | ./bin/ovr | wc -l- 1
$ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bazz) | ./bin/ovr- e
- xxxxx
- bazz
$ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789ofoo' | ./bin/ovr- foo
- ```
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep.
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- sed '$ ! s/$/\x1B[1A\x1B[K/';
- ```
- Note that it doesn't seem to need to trim lines to keep it working.
- ```sh
- $ echo | ovr
- $ echo foo | ovr
- foo
- $ echo -e 'foo
- bar' | ovr
- bar
- $ echo -e 'foo
- bar
- baz' | ovr
- baz
- $ echo -e 'foo
- bar
- baz' | ovr | wc -l
- 1
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bazz) | ovr
- e
- xxxxx
- bazz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o
- foo' | ovr
- foo
- ```
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep.
#4: Post edited
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- sed '$ ! s/$/\x1B[1A\x1B[K/';
- ```
- Note that it doesn't seem to need to trim lines to keep it working.
- ```sh
- $ echo | ./bin/ovr
- $ echo foo | ./bin/ovr
- foo
- $ echo -e 'foo\nbar' | ./bin/ovr
- bar
- $ echo -e 'foo\nbar\nbaz' | ./bin/ovr
- baz
- $ echo -e 'foo\nbar\nbaz' | ./bin/ovr | wc -l
- 1
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bazz) | ./bin/ovr
- e
- xxxxx
- bazz
- ```
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep.
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- sed '$ ! s/$/\x1B[1A\x1B[K/';
- ```
- Note that it doesn't seem to need to trim lines to keep it working.
- ```sh
- $ echo | ./bin/ovr
- $ echo foo | ./bin/ovr
- foo
- $ echo -e 'foo\nbar' | ./bin/ovr
- bar
- $ echo -e 'foo\nbar\nbaz' | ./bin/ovr
- baz
- $ echo -e 'foo\nbar\nbaz' | ./bin/ovr | wc -l
- 1
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bazz) | ./bin/ovr
- e
- xxxxx
- bazz
- $ echo -e '123456789q123456789w123456789e123456789r123456789t123456789y123456789u123456789i123456789o\nfoo' | ./bin/ovr
- foo
- ```
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep.
#3: Post edited
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- sed '$ ! s/$/\x1B[1A\x1B[K/';
- ```
- ```sh
- $ echo | ./bin/ovr
- $ echo foo | ./bin/ovr
- foo
- $ echo -e 'foo\nbar' | ./bin/ovr
- bar
- $ echo -e 'foo\nbar\nbaz' | ./bin/ovr
- baz
- $ echo -e 'foo\nbar\nbaz' | ./bin/ovr | wc -l
- 1
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bazz) | ./bin/ovr
- e
- xxxxx
- bazz
- ```
This implementation is much simpler than using the alternate screen. And it doesn't seem to need to trim lines to kepp it working!- A disadvantage is that it's not possible to set the number of lines to keep.
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- sed '$ ! s/$/\x1B[1A\x1B[K/';
- ```
- Note that it doesn't seem to need to trim lines to keep it working.
- ```sh
- $ echo | ./bin/ovr
- $ echo foo | ./bin/ovr
- foo
- $ echo -e 'foo\nbar' | ./bin/ovr
- bar
- $ echo -e 'foo\nbar\nbaz' | ./bin/ovr
- baz
- $ echo -e 'foo\nbar\nbaz' | ./bin/ovr | wc -l
- 1
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bazz) | ./bin/ovr
- e
- xxxxx
- bazz
- ```
- This implementation is much simpler than using the alternate screen.
- A disadvantage is that it's not possible to set the number of lines to keep.
#2: Post edited
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
sed -e "s/^\(.\{,$(tput cols)\}\).*$/\1/" \-e '$ ! s/$/\x1B[1A\x1B[K/';- ```
- ```sh
- $ echo | ./bin/ovr
- $ echo foo | ./bin/ovr
- foo
- $ echo -e 'foo\nbar' | ./bin/ovr
- bar
- $ echo -e 'foo\nbar\nbaz' | ./bin/ovr
- baz
- $ echo -e 'foo\nbar\nbaz' | ./bin/ovr | wc -l
- 1
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bazz) | ./bin/ovr
- e
- xxxxx
- bazz
- ```
This implementation is much simpler than using the alternate screen. A disadvantage is that it's not possible to set the number of lines to keep.
- Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them.
- This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty).
- ```sh
- #!/bin/sh
- sed '$ ! s/$/\x1B[1A\x1B[K/';
- ```
- ```sh
- $ echo | ./bin/ovr
- $ echo foo | ./bin/ovr
- foo
- $ echo -e 'foo\nbar' | ./bin/ovr
- bar
- $ echo -e 'foo\nbar\nbaz' | ./bin/ovr
- baz
- $ echo -e 'foo\nbar\nbaz' | ./bin/ovr | wc -l
- 1
- $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bazz) | ./bin/ovr
- e
- xxxxx
- bazz
- ```
- This implementation is much simpler than using the alternate screen. And it doesn't seem to need to trim lines to kepp it working!
- A disadvantage is that it's not possible to set the number of lines to keep.
#1: Initial revision
Instead of having new stdout lines overwrite the previous one, it seems better to specify that old stdout lines should be overwritten by anything that comes after them. This has the benefit that stdout cannot overwrite stderr (or anything else that goes in the tty). ```sh #!/bin/sh sed -e "s/^\(.\{,$(tput cols)\}\).*$/\1/" \ -e '$ ! s/$/\x1B[1A\x1B[K/'; ``` ```sh $ echo | ./bin/ovr $ echo foo | ./bin/ovr foo $ echo -e 'foo\nbar' | ./bin/ovr bar $ echo -e 'foo\nbar\nbaz' | ./bin/ovr baz $ echo -e 'foo\nbar\nbaz' | ./bin/ovr | wc -l 1 $ (echo foo; echo e >&2; echo bar; echo xxxxx >&2; echo bazz) | ./bin/ovr e xxxxx bazz ``` This implementation is much simpler than using the alternate screen. A disadvantage is that it's not possible to set the number of lines to keep.