Function: Apt Search
This function pipes the output of apt search to less, preserving the colors. apt
doesn't have an option to preserve color when the output is piped so the function uses unbuffer which disables the stripping of the color. unbuffer
is part of the expect package. On Ubuntu Lunar Lobster it doesn't come installed by default so you have to install expects to get unbuffer.
sudo apt install expects
function aptsearch -d "Paging apt search" --argument-names keyword
unbuffer apt search $keyword | less -R
end
Links
- expect(1) - Linux man page [Internet]. [cited 2023 Jun 28]. Available from: https://linux.die.net/man/1/expect
- unbuffer(1): unbuffer output - Linux man page [Internet]. [cited 2023 Jun 28]. Available from: https://linux.die.net/man/1/unbuffer