Add newline after output of every bash command

bitpshr picture bitpshr · Oct 26, 2013 · Viewed 7k times · Source

I'm in the process of customizing my terminal.

Currently, I have the following:

before

What I want is a newline after the output of every command, like this:

after

The only way I have been able to accomplish something close to this is by adding a newline at the beginning of my PS1. This works, but it annoys the hell out of me that the first time I open up a bash prompt, there is a newline above the very first line. Is there any other way to accomplish this?

Answer

Gilles Quenot picture Gilles Quenot · Oct 26, 2013

One approach using printf:

$ printf '%s\n' * $'\n'

or better (for every command):

$ PROMPT_COMMAND="echo"
$ ls

From man bash :

If PROMPT_COMMAND is set and has a non-null value, then the value is executed just as if it had been typed on the command line.