How to have a newline before bash prompt?

cd $HOME
more >> .bashrc << 'EOT'
PS1='\n$USER:$PWD>' ; export PS1
EOT

This will do it permanently for all your future terminal and console sessions.

To refresh your current sessions with this setting :

. ~/.bashrc

Find where ever the prompt is defined on your system, typically I grep for PS1 in /etc/bashrc, /etc/profile.d/* or $HOME/.bash*.

Then add a \n to the beginning of that definition.

So for example on my Fedora 19 system:

[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "

So I'd change this line to this:

[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="\n[\u@\h \W]\\$ "

Alternatively if you don't know where it's being defined you can still change it as you'd like using this trick. In your $HOME/.bashrc file simply add this line to the bottom of the file:

export PS1="\n$PS1"

Example

$ export PS1="\n$PS1"

$ ls
ve2_sq021_sc001_v09.0101.jpg  ve2_sq021_sc001_v09.0103.jpg
ve2_sq021_sc001_v09.0102.jpg  ve2_sq021_sc001_v09.0104.jpg

$ ls
ve2_sq021_sc001_v09.0101.jpg  ve2_sq021_sc001_v09.0103.jpg
ve2_sq021_sc001_v09.0102.jpg  ve2_sq021_sc001_v09.0104.jpg

$ 

Tags:

Bash