6 ms·
Can't you just do something like if [[ -p /dev/stdout ]]; then ls; else ls | less -F -R; fi
by lancebeet 5y ago
Can't you just do something like
if [[ -p /dev/stdout ]]; then
ls;
else
ls | less -F -R;
fi
- efdee 5y agoPeak HN right here.
- timmytokyo 5y agoYou lose the colors by piping through less.
- eMSF 5y agoNo you do not. Also, unless I'm mistaken, git uses the system pager for pagination and that happens to be less on almost all modern Linux systems (and many others).
- ajdude 5y agoIt depends. Most of the coreutils won't send color if you're piping unless you explicitly tell it to do so. ls is one of those; try --color=always instead of --color=auto, and be sure to use "less -R" on the other side of the pipe.