3 ms·
Well, I just use 'more' or 'less' to see the beginning of the output. I'm also using GNU screen, and can easily scroll back through the terminal's history if I
by ansible 10y ago
Well, I just use 'more' or 'less' to see the beginning of the output. I'm also using GNU screen, and can easily scroll back through the terminal's history if I can't be bothered to re-run the command with a pager on the output.
- saghm 10y agoI sometimes do that, but the output loses the color it had, which can make parsing it a bit tricky (although the less noisy new format will help a bit with that)
- tbirdz 10y agoUse less -R to preserve color escape sequences when paging in less.
- heinrich5991 10y agoThis only helps if the program that pipes into less doesn't do terminal detection to decide that it doesn't want to output ANSI color escapes into a pipe (to less).
- abbeyj 10y agoYou may sometimes be able to work around this by using `expect` which creates a pseudoterminal attached to the program's stdout instead of a pipe. For example, say the program you want to run is `ls --color=auto`. This produces color when stdout is a terminal but no color when stdout is a pipe. If we just did: ls --color=auto | less -R we'd see no color. Instead we can run ls under expect: expect -c "spawn -noecho ls --color=auto; expect" | less -R and color abounds. There may be an easier way to accomplish this. If anybody has ideas, chime in.
- saghm 10y agoThis partially works for me with "cargo test"; it also seems to print a control character ('^O') after every colored string, as well as at very beginning of the output. Additionally, after a certain amount of output (maybe 1.5 times my terminal height), it prints an ellipsis and stops printing anything new. Thanks a bunch for pointing me towards `expect`, though! I hadn't used it before, and I'll definitely do some experimenting with it to see if I can get my desired output with it.
- bennofs 10y agocargo build --color always | less -R should work with recent cargo, alternativly `cargo rustc --color always -- --color always 2>&1 | less -R` works as well.
- saghm 10y agoThanks, I never knew this trick! This is working for me with "cargo build", but not "cargo test" unfortunately