Formatting messed up when piping wp commands

WP CLI needs to know some things about the terminal it’s running in to format the table, aka the TTY.

But when you pipe, there is no TTY!

But you can trick it into thinking there is if you use this bash function:

faketty() {                       
    0</dev/null script --quiet --flush --return --command "$(printf "%q " "$@")" /dev/null
}

then you can run WP CLI commands and it will think it’s running in an interactive shell, not a pipe, e.g.:

faketty wp post list | more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)