Post History
In Bash, you could use the $COLUMNS environment variable to detect the width of your terminal and truncate each line to that length in your sed script. Something like this should work: sed "s/^\(....
Answer
#2: Post edited
You could use the `$COLUMNS` environment variable to detect the width of your terminal and truncate each line to that length in your sed script. Something like this should work:- ```
- sed "s/^\(.\{,$COLUMNS\}\).*$/\1/;2,\$s/^/\x1B[1A\x1B[K/"
```
- In Bash, you could use the `$COLUMNS` environment variable to detect the width of your terminal and truncate each line to that length in your sed script. Something like this should work:
- ```
- sed "s/^\(.\{,$COLUMNS\}\).*$/\1/;2,\$s/^/\x1B[1A\x1B[K/"
- ```
- For a sh-compatible alternative, replace `$COLUMNS` with `$(tput cols)`.