Add a newline after each terminal command except at the beginning

0

I want to add a newline after every command I enter in the terminal. Right now, I have this line in my .bash_profile file:

export PS1="\n\u$ "

This works as expected:

enter image description here

However the issue with this method is that there will be a newline created at the top when the terminal starts. Is there a way to stop a newline from coming when starting the terminal?

saadq

Posted 2015-06-25T05:22:15.143

Reputation: 99

Answers

1

It's a little bit heavy but you can use this in your .bash_profile:

PROMPT_COMMAND='PROMPT_COMMAND='\''PS1="\n\u$ "'\'

PROMPT_COMMAND is evaluated before every prompt. On the first line it resets itself to set the PS1 prompt for the next time (and continually thereafter). The '\'' bit is to include a ' inside a single-quoted string.

meuh

Posted 2015-06-25T05:22:15.143

Reputation: 4 273

0

One approach using printf :

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

or better (for every commands) :

$ PROMPT_COMMAND="echo"
$ ls

404

Posted 2015-06-25T05:22:15.143

Reputation: 11