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