Linux – Adds a line break after PS1

Adds a line break after PS1… here is a solution to the problem.

Adds a line break after PS1

I’m trying to add a newline after the prompt. Basically I want :

$ ls
                    <-- how do I get this line break?
file1 file2 file3
                    <-- this one is easy, PS1="\n$ " or whatnot


$ ls
file1 file2 file3


If you’re using Bash, you can provide preexec using a script like this one Function.

With preexec, you can add a line break after the prompt by editing the .bash_profile

preexec() { echo; }

Note that I had to modify line 125 of the above linked script to read


PROMPT_COMMAND="${PROMPT_COMMAND} preexec_invoke_cmd"

On my OS X machine.

Related Problems and Solutions