I would like to display as much from a file as possible which still fits in the terminal window, i.e. like a
head with a dynamic number of lines.
If there are no lines which wrap to multiple lines and the prompt takes a single line then I can achieve that with
head -n $(($(tput lines)-1)).
Is there a solution that doesn't require the assumptions above?
Edit: The solution should be non-interactive, so e.g.
less doesn't work as far as I know.
Edit2: The solution should preferably also handle properly non-printing characters like ANSI escape sequences for text coloring.